Return-Path: X-Original-To: apmail-struts-issues-archive@minotaur.apache.org Delivered-To: apmail-struts-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A1CB318227 for ; Wed, 13 May 2015 04:55:05 +0000 (UTC) Received: (qmail 67515 invoked by uid 500); 13 May 2015 04:55:00 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 67480 invoked by uid 500); 13 May 2015 04:55:00 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 67466 invoked by uid 99); 13 May 2015 04:55:00 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2015 04:55:00 +0000 Date: Wed, 13 May 2015 04:55:00 +0000 (UTC) From: "Lukasz Lenart (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (WW-4437) Bug in CookieInterceptor MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/WW-4437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14541322#comment-14541322 ] Lukasz Lenart commented on WW-4437: ----------------------------------- You should throw it away, FM was upgrade to the latest available version 2.3.24, see WW-4484 and it's set to be backward compatible http://struts.apache.org/docs/freemarker.html#FreeMarker-IncompatibleImprovements > 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.24 > > > 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)