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

markt-asf 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 ae551ecd26 Review "Escape literal single quotes in Strftime 
SimpleDateFormat..."
ae551ecd26 is described below

commit ae551ecd26ff86b3a446bfaaf8ed1e56e2d489ca
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Oct 23 22:42:45 2026 +0100

    Review "Escape literal single quotes in Strftime SimpleDateFormat..."
    
    Add some additional escaping with test case
---
 java/org/apache/catalina/util/Strftime.java     | 2 +-
 test/org/apache/catalina/util/TestStrftime.java | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/util/Strftime.java 
b/java/org/apache/catalina/util/Strftime.java
index afc5a36b51..9297dfcc18 100644
--- a/java/org/apache/catalina/util/Strftime.java
+++ b/java/org/apache/catalina/util/Strftime.java
@@ -221,7 +221,7 @@ public class Strftime {
      * @return the quoted string
      */
     protected String quote(String str, boolean insideQuotes) {
-        String retVal = str;
+        String retVal = str.replace("'", "''");
         if (!insideQuotes) {
             retVal = '\'' + retVal + '\'';
         }
diff --git a/test/org/apache/catalina/util/TestStrftime.java 
b/test/org/apache/catalina/util/TestStrftime.java
index 4b9214653a..067ca813ac 100644
--- a/test/org/apache/catalina/util/TestStrftime.java
+++ b/test/org/apache/catalina/util/TestStrftime.java
@@ -62,6 +62,13 @@ public class TestStrftime {
         Assert.assertEquals("a' b", format("a' b"));
     }
 
+    @Test
+    public void testQuoteAsUnknownCommand() {
+        Assert.assertEquals("%'", format("%'"));
+        Assert.assertEquals("a%'b", format("a%'b"));
+        Assert.assertEquals("%'", format("%E'"));
+    }
+
     /*
      * A pattern of the kind SSI config timefmt values commonly use, with the 
literal word 'GMT' quoted.
      */


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to