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 19a240ae13 follow  valid text rewrite map file syntax mentioned in 
httpd apache docs#rewritemap
19a240ae13 is described below

commit 19a240ae13eaeeb62eedf178173cc5385a26b48f
Author: Chenjp <ch...@msn.com>
AuthorDate: Tue Jun 3 15:58:23 2025 +0800

    follow  valid text rewrite map file syntax mentioned in httpd apache 
docs#rewritemap
    
    enable support for plain text rewrite map
    MatchingKey SubstValue # comment
---
 .../org/apache/catalina/valves/rewrite/RandomizedTextRewriteMap.java | 5 ++++-
 test/conf/TesterRewriteMapB.txt                                      | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git 
a/java/org/apache/catalina/valves/rewrite/RandomizedTextRewriteMap.java 
b/java/org/apache/catalina/valves/rewrite/RandomizedTextRewriteMap.java
index d9d98ddc93..2b6ccce5f9 100644
--- a/java/org/apache/catalina/valves/rewrite/RandomizedTextRewriteMap.java
+++ b/java/org/apache/catalina/valves/rewrite/RandomizedTextRewriteMap.java
@@ -50,8 +50,11 @@ public class RandomizedTextRewriteMap implements RewriteMap {
                 BufferedReader reader = new BufferedReader(new 
InputStreamReader(txtResource.getInputStream()))) {
             while ((line = reader.readLine()) != null) {
                 if (line.startsWith("#") || line.isEmpty()) {
-                    // Ignore comment or empty lines
+                    // Ignore comment line or empty lines
                     continue;
+                } else if (line.indexOf('#') > 0) {
+                    // comment characters after '#'
+                    line = line.substring(0, line.indexOf('#')).trim();
                 }
                 String[] keyValuePair = line.split(" ", 2);
                 if (keyValuePair.length > 1) {
diff --git a/test/conf/TesterRewriteMapB.txt b/test/conf/TesterRewriteMapB.txt
index 3817ad7753..e268e5dd28 100644
--- a/test/conf/TesterRewriteMapB.txt
+++ b/test/conf/TesterRewriteMapB.txt
@@ -20,5 +20,5 @@
 
 a aa
 
-aa aaaa
-b bb
+aa aaaa #abc
+b bb #abc


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

Reply via email to