354397 RewriteRegexRule handles special characters in regex group

This commit is contained in:
Michael Gorovoy 2011-08-15 12:24:07 -04:00
parent bfda9e0523
commit 6fb751e216
3 changed files with 5 additions and 2 deletions

View File

@ -17,6 +17,7 @@ jetty-7.5.0-SNAPSHOT
+ 353862 Improve performance of QuotedStringTokenizer.quote()
+ 354014 Content-Length is passed to wrapped response in GZipFilter
+ 354204 Charset encodings property file not used
+ 354397 RewriteRegexRule handles special characters in regex group
+ 354466 Typo in example config of jetty-plus.xml
jetty-7.4.4.v20110707 July 7th 2011

View File

@ -56,7 +56,7 @@ public class RewriteRegexRule extends RegexRule implements Rule.ApplyURI
target=_replacement;
for (int g=1;g<=matcher.groupCount();g++)
{
String group = matcher.group(g);
String group = Matcher.quoteReplacement(matcher.group(g));
target=target.replaceAll("\\$"+g,group);
}
@ -73,7 +73,7 @@ public class RewriteRegexRule extends RegexRule implements Rule.ApplyURI
String uri=_replacement;
for (int g=1;g<=matcher.groupCount();g++)
{
String group = matcher.group(g);
String group = Matcher.quoteReplacement(matcher.group(g));
uri=uri.replaceAll("\\$"+g,group);
}
request.setRequestURI(uri);

View File

@ -26,6 +26,8 @@ public class RewriteRegexRuleTest extends AbstractRuleTestCase
{"/foo/bar",".*","/replace","/replace"},
{"/foo/bar","/xxx.*","/replace",null},
{"/foo/bar","/(.*)/(.*)","/$2/$1/xxx","/bar/foo/xxx"},
{"/foo/$bar",".*","/$replace","/$replace"},
{"/foo/$bar","/foo/(.*)","/$1/replace","/$bar/replace"},
};
private RewriteRegexRule _rule;