Author: markt
Date: Mon Sep 12 20:33:07 2016
New Revision: 1760446
URL: http://svn.apache.org/viewvc?rev=1760446&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=60116
Fix a problem with the rewrite valve that caused back references evaluated in
conditions to be forced to lower case when using the NC flag.
Modified:
tomcat/trunk/java/org/apache/catalina/valves/rewrite/RewriteCond.java
tomcat/trunk/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/catalina/valves/rewrite/RewriteCond.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/rewrite/RewriteCond.java?rev=1760446&r1=1760445&r2=1760446&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/rewrite/RewriteCond.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/valves/rewrite/RewriteCond.java Mon
Sep 12 20:33:07 2016
@@ -16,7 +16,6 @@
*/
package org.apache.catalina.valves.rewrite;
-import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -188,9 +187,6 @@ public class RewriteCond {
*/
public boolean evaluate(Matcher rule, Matcher cond, Resolver resolver) {
String value = test.evaluate(rule, cond, resolver);
- if (nocase) {
- value = value.toLowerCase(Locale.ENGLISH);
- }
Condition condition = this.condition.get();
if (condition == null) {
if (condPattern.startsWith("<")) {
Modified:
tomcat/trunk/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java?rev=1760446&r1=1760445&r2=1760446&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
Mon Sep 12 20:33:07 2016
@@ -447,6 +447,15 @@ public class TestRewriteValve extends To
}
+ @Test
+ public void testFlagsNC() throws Exception {
+ // https://bz.apache.org/bugzilla/show_bug.cgi?id=60116
+ doTestRewrite("RewriteCond %{QUERY_STRING} a=([a-z]*) [NC]\n"
+ + "RewriteRule .* - [E=X-Test:%1]",
+ "/c?a=aAa", "/c", null, "aAa");
+ }
+
+
private void doTestRewrite(String config, String request, String
expectedURI) throws Exception {
doTestRewrite(config, request, expectedURI, null);
}
@@ -454,6 +463,11 @@ public class TestRewriteValve extends To
private void doTestRewrite(String config, String request, String
expectedURI,
String expectedQueryString) throws Exception {
+ doTestRewrite(config, request, expectedURI, expectedQueryString, null);
+ }
+
+ private void doTestRewrite(String config, String request, String
expectedURI,
+ String expectedQueryString, String expectedAttributeValue)
throws Exception {
Tomcat tomcat = getTomcatInstance();
@@ -485,5 +499,10 @@ public class TestRewriteValve extends To
String queryString =
requestDesc.getRequestInfo("REQUEST-QUERY-STRING");
Assert.assertEquals(expectedQueryString, queryString);
}
+
+ if (expectedAttributeValue != null) {
+ String attrbuteValue = requestDesc.getAttribute("X-Test");
+ Assert.assertEquals(expectedAttributeValue, attrbuteValue);
+ }
}
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1760446&r1=1760445&r2=1760446&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Mon Sep 12 20:33:07 2016
@@ -59,6 +59,11 @@
improve the handling for the <code>QSA</code> flag. Includes multiple
test cases by Santhana Preethi. (markt)
</fix>
+ <fix>
+ <bug>60116</bug>: Fix a problem with the rewrite valve that caused back
+ references evaluated in conditions to be forced to lower case when
using
+ the <code>NC</code> flag. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]