[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-dev
Subject:    [jira] [Commented] (WW-4437) Bug in CookieInterceptor
From:       "Hudson (JIRA)" <jira () apache ! org>
Date:       2014-12-31 17:33:16
Message-ID: JIRA.12762885.1419006498000.122525.1420047196747 () Atlassian ! JIRA
[Download RAW message or body]


    [ https://issues.apache.org/jira/browse/WW-4437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14262325#comment-14262325 \
] 

Hudson commented on WW-4437:
----------------------------

FAILURE: Integrated in Struts-JDK6-master #901 (See \
[https://builds.apache.org/job/Struts-JDK6-master/901/]) WW-4437 Fixes problem with \
                accepted params (lukaszlenart: rev \
                40822d67f5b6b667bb2760986cb78efc9e2e3ac4)
* core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
* core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java


> Bug in CookieInterceptor
> ------------------------
> 
> Key: WW-4437
> URL: https://issues.apache.org/jira/browse/WW-4437
> Project: Struts 2
> Issue Type: Bug
> Components: Core Interceptors
> Affects Versions: 2.3.20
> Reporter: Chris Pratt
> Assignee: Lukasz Lenart
> Fix For: 2.3.21
> 
> 
> Sorry, I don't have an environment set up to create a patch, but I found an error \
> in the {{CookieInterceptor.isAccepted()}} method.  It currently looks like: \
> {code:java} /**
> * Checks if name of Cookie match {@link #acceptedPattern}
> *
> * @param name of Cookie
> * @return true|false
> */
> protected boolean isAccepted(String name) {
> boolean matches = acceptedPattern.matcher(name).matches();
> if (matches) {
> if (LOG.isTraceEnabled()) {
> LOG.trace("Cookie [#0] matches acceptedPattern [#1]", name, ACCEPTED_PATTERN);
> }
> } else {
> if (LOG.isTraceEnabled()) {
> LOG.trace("Cookie [#0] doesn't match acceptedPattern [#1]", name, \
> ACCEPTED_PATTERN); }
> }
> return matches;
> }
> {code}
> But it would be more useful if it actually reported the RegEx being used instead of \
> the default.  And, it would be more performant if the comparisons were reversed.  \
> So something more like: {code:java}
> /**
> * Checks if name of Cookie match {@link #acceptedPattern}
> *
> * @param name of Cookie
> * @return true|false
> */
> protected boolean isAccepted (String name) {
> boolean matches = acceptedPattern.matcher(name).matches();
> if(LOG.isTraceEnabled()) {   
> if(matches) {
> LOG.trace("Cookie [#0] matches acceptedPattern \
> [#1]",name,acceptedPattern.pattern()); } else {
> LOG.trace("Cookie [#0] doesn't match acceptedPattern \
> [#1]",name,acceptedPattern.pattern()); }
> }
> return matches;
> }
> {code}
> In addition, it looks like the default and the override are handled differently.  \
> The current code compiles the default case-insensitive, but not the override \
> pattern.  Shouldn't that be consistent? {code:java}
> private Pattern acceptedPattern = \
> Pattern.compile(ACCEPTED_PATTERN,Pattern.CASE_INSENSITIVE); public void \
> setAcceptCookieNames (String pattern) { acceptedPattern = Pattern.compile(pattern);
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic