You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/09/30 19:22:21 UTC

[tomcat] branch 8.5.x updated: Update RewriteValve to use dotall mode

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 75d11526ef Update RewriteValve to use dotall mode
75d11526ef is described below

commit 75d11526eff3e590490288b89d17fe1903e7da9a
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Sep 30 20:19:42 2022 +0100

    Update RewriteValve to use dotall mode
---
 java/org/apache/catalina/valves/rewrite/RewriteCond.java | 2 +-
 java/org/apache/catalina/valves/rewrite/RewriteRule.java | 4 ++--
 webapps/docs/changelog.xml                               | 5 +++++
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/valves/rewrite/RewriteCond.java b/java/org/apache/catalina/valves/rewrite/RewriteCond.java
index 47a904c1e0..90bdc5289a 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteCond.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteCond.java
@@ -151,7 +151,7 @@ public class RewriteCond {
             this.condition = ncondition;
         } else {
             PatternCondition ncondition = new PatternCondition();
-            int flags = 0;
+            int flags = Pattern.DOTALL;
             if (isNocase()) {
                 flags |= Pattern.CASE_INSENSITIVE;
             }
diff --git a/java/org/apache/catalina/valves/rewrite/RewriteRule.java b/java/org/apache/catalina/valves/rewrite/RewriteRule.java
index 833a12c177..f4fd9b665c 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteRule.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteRule.java
@@ -47,7 +47,7 @@ public class RewriteRule {
             positive = false;
             patternString = patternString.substring(1);
         }
-        int flags = 0;
+        int flags = Pattern.DOTALL;
         if (isNocase()) {
             flags |= Pattern.CASE_INSENSITIVE;
         }
@@ -89,7 +89,7 @@ public class RewriteRule {
         Pattern pattern = this.pattern.get();
         if (pattern == null) {
             // Parse the pattern
-            int flags = 0;
+            int flags = Pattern.DOTALL;
             if (isNocase()) {
                 flags |= Pattern.CASE_INSENSITIVE;
             }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e1da0113de..d65398bf58 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -147,6 +147,11 @@
         <code>ErrorReportValve</code> that returns  response as JSON instead of
         HTML. Back-porting kfujino's implementation. (lihan)
       </add>
+      <fix>
+        Update the <code>RewriteValve</code> to perform pattern matching using
+        dotall mode to avoid unexpected behaviour if the URL includes encoded
+        line terminators. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org