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

lihan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 6a5ef86802 Fix BZ 66393 - Align ExtendedAccessLogValve's x-P(XXX) with 
the documentation.
6a5ef86802 is described below

commit 6a5ef86802883a34f7e24865d0d37158d50d9b9c
Author: lihan <li...@apache.org>
AuthorDate: Tue Dec 20 18:21:56 2022 +0800

    Fix BZ 66393 - Align ExtendedAccessLogValve's x-P(XXX) with the 
documentation.
    
    https://bz.apache.org/bugzilla/show_bug.cgi?id=66393
---
 java/org/apache/catalina/valves/ExtendedAccessLogValve.java | 11 +++--------
 webapps/docs/changelog.xml                                  |  4 ++++
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java 
b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
index 852a473c43..f9e97dda18 100644
--- a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
+++ b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
@@ -19,9 +19,8 @@ package org.apache.catalina.valves;
 import java.io.CharArrayWriter;
 import java.io.IOException;
 import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
 import java.net.InetAddress;
-import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -36,6 +35,7 @@ import jakarta.servlet.http.HttpSession;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.util.ServerInfo;
+import org.apache.catalina.util.URLEncoder;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
@@ -399,12 +399,7 @@ public class ExtendedAccessLogValve extends AccessLogValve 
{
             if (null==value || value.length()==0) {
                 return null;
             }
-            try {
-                return URLEncoder.encode(value, "UTF-8");
-            } catch (UnsupportedEncodingException e) {
-                // Should never happen - all JVMs are required to support UTF-8
-                return null;
-            }
+            return URLEncoder.QUERY.encode(value, StandardCharsets.UTF_8);
         }
 
         @Override
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 6475f10adb..db6edb18cf 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -124,6 +124,10 @@
         <bug>66392</bug>: Change the default value of 
<code>AccessLogValue</code>'s
         file encoding to UTF-8 and update documentation. (lihan)
       </fix>
+      <fix>
+        <bug>66393</bug>: Align <code>ExtendedAccessLogValve</code>'s x-P(XXX) 
with the
+        documentation. (lihan)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


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

Reply via email to