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:21:21 UTC

[tomcat] branch 9.0.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 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


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

commit 3e31c41c93d8271acc5de780f81c3b2b266e9ca2
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                               | 9 +++++++++
 3 files changed, 12 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 ca29223deb..d055882a13 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 2381a62cb9..7489d3762d 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,15 @@
   issues do not "pop up" wrt. others).
 -->
 <section name="Tomcat 9.0.68 (remm)" rtext="in development">
+  <subsection name="Catalina">
+    <changelog>
+      <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">
     <changelog>
       <fix>


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