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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new e4f9ac923c Align escaping ExtendedAccessLogValve with the other 
implementations
e4f9ac923c is described below

commit e4f9ac923ced912a50e0ae13d8ca5dc4bb5a1774
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Apr 8 12:23:07 2026 +0100

    Align escaping ExtendedAccessLogValve with the other implementations
---
 .../catalina/valves/ExtendedAccessLogValve.java    | 37 ++++++++++++++--------
 webapps/docs/changelog.xml                         |  4 +++
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java 
b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
index 69d3b690a6..2be0851bb6 100644
--- a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
+++ b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
@@ -588,13 +588,18 @@ public class ExtendedAccessLogValve extends 
AccessLogValve {
                     } else if ("query".equals(token)) {
                         return new AccessLogElement() {
                             @Override
-                            public void addElement(CharArrayWriter buf, 
Request request, Response response,
-                                    long time) {
-                                String query = request.getQueryString();
-                                if (query != null) {
-                                    buf.append(query);
-                                } else {
+                            public void addElement(CharArrayWriter buf, 
Request request, Response response, long time) {
+                                String query = null;
+                                if (request != null) {
+                                    query = request.getQueryString();
+                                }
+                                if (query == null) {
                                     buf.append('-');
+                                } else if (query.isEmpty()) {
+                                    // NO-OP
+                                    // Don't want to write "-" if the query 
string is present but empty
+                                } else {
+                                    escapeAndAppend(query, buf, true);
                                 }
                             }
                         };
@@ -602,13 +607,19 @@ public class ExtendedAccessLogValve extends 
AccessLogValve {
                 } else {
                     return new AccessLogElement() {
                         @Override
-                        public void addElement(CharArrayWriter buf, Request 
request, Response response,
-                                long time) {
-                            String query = request.getQueryString();
-                            buf.append(request.getRequestURI());
-                            if (query != null) {
-                                buf.append('?');
-                                buf.append(request.getQueryString());
+                        public void addElement(CharArrayWriter buf, Request 
request, Response response, long time) {
+                            if (request != null) {
+                                escapeAndAppend(request.getRequestURI(), buf);
+                                String query = request.getQueryString();
+                                if (query != null) {
+                                    buf.append('?');
+                                    // Don't want to write "-" if the query 
string is present but empty
+                                    if (!query.isEmpty()) {
+                                        buf.append(request.getQueryString());
+                                    }
+                                }
+                            } else {
+                                buf.append('-');
                             }
                         }
                     };
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index a96360c01f..4911b4c411 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -120,6 +120,10 @@
         Failed precondition should make WebDAV DELETE fail. <pr>982</pr>
         submitted by Mahmoud Alarby. (remm)
       </fix>
+      <fix>
+        Align the escaping in <code>ExtendedAccessLogValve</code> with the 
other
+        <code>AccessLogValve</code> implementations. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


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

Reply via email to