peony2012 / urlrewritefilter

Automatically exported from code.google.com/p/urlrewritefilter
Other
0 stars 0 forks source link

Variable names containing underscores treated as a literal string in 4.0.3 #157

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
After upgrading from 3.2.0 to 4.0.3 urlrewritefilter is unable to recognize my 
variables.

With an entry like this in urlrewrite.xml:

    <set name="cookie-value">%{cookie:cookie_name}</set>

I used to see either the cookie contents in the attribute cookie-value (or null 
in case of a non-existing cookie).

Using 4.0.3 I see the literal string '%{cookie:cookie_name}' which is 
unexpected. If underscore is not a valid token in variable one would expect 
either an exception to be thrown or in the worst case null should be assigned 
to the cookie-value attribute.

I fail to see why under shouldn't be allowed as a variable name token as it 
limits the possibilities to make cookies and query strings (which often aren't 
under your direct control).

I'm running the code on both Linux and Mac OS X (in development).

The interesting code snippets are:

https://code.google.com/p/urlrewritefilter/source/browse/tags/3.2.0/src/java/org
/tuckey/web/filters/urlrewrite/VariableReplacer.java
 private static Pattern toVariablePattern = Pattern.compile("(?<!\\\\)%\\{(.*?)\\}");

https://code.google.com/p/urlrewritefilter/source/browse/tags/4.0.1/src/java/org
/tuckey/web/filters/urlrewrite/substitution/VariableReplacer.java
    private static Pattern toVariablePattern = Pattern.compile("(?<!\\\\)%\\{([-a-zA-Z:]*)\\}");

Original issue reported on code.google.com by mr.krist...@gmail.com on 3 Feb 2014 at 12:25