This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 62983467e4 Review "Escape literal single quotes in Strftime
SimpleDateFormat..."
62983467e4 is described below
commit 62983467e4db71479aec855de0d419cfa4e2bc9f
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 b735c3119d..b08f94304f 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]