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

markt-asf 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 7fa5466bde Restore previous null behaviour. Output "?"
7fa5466bde is described below

commit 7fa5466bdeefd5874d149597fbc74bb5d9691246
Author: Mark Thomas <[email protected]>
AuthorDate: Tue May 26 17:16:34 2026 +0100

    Restore previous null behaviour. Output "&#63;"
    
    This also aligns null handling with the rest of this code block
---
 .../apache/catalina/manager/StatusTransformer.java | 31 +++++++++++-----------
 java/org/apache/tomcat/util/security/Escape.java   | 15 +++++++++++
 2 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/java/org/apache/catalina/manager/StatusTransformer.java 
b/java/org/apache/catalina/manager/StatusTransformer.java
index a3332881c1..c52366f171 100644
--- a/java/org/apache/catalina/manager/StatusTransformer.java
+++ b/java/org/apache/catalina/manager/StatusTransformer.java
@@ -53,8 +53,9 @@ public class StatusTransformer {
 
     /**
      * Sets the response content type based on the output mode.
+     *
      * @param response the HTTP response
-     * @param mode 0 for HTML, 1 for XML, 2 for JSON
+     * @param mode     0 for HTML, 1 for XML, 2 for JSON
      */
     public static void setContentType(HttpServletResponse response, int mode) {
         if (mode == 0) {
@@ -118,9 +119,10 @@ public class StatusTransformer {
 
     /**
      * Writes the page heading section.
+     *
      * @param writer the output writer
-     * @param args formatting arguments
-     * @param mode output mode (0=HTML)
+     * @param args   formatting arguments
+     * @param mode   output mode (0=HTML)
      */
     public static void writePageHeading(PrintWriter writer, Object[] args, int 
mode) {
         if (mode == 0) {
@@ -131,9 +133,10 @@ public class StatusTransformer {
 
     /**
      * Writes the server information row.
+     *
      * @param writer the output writer
-     * @param args formatting arguments
-     * @param mode output mode (0=HTML)
+     * @param args   formatting arguments
+     * @param mode   output mode (0=HTML)
      */
     public static void writeServerInfo(PrintWriter writer, Object[] args, int 
mode) {
         if (mode == 0) {
@@ -144,8 +147,9 @@ public class StatusTransformer {
 
     /**
      * Writes the page footer.
+     *
      * @param writer the output writer
-     * @param mode output mode (0=HTML, 1=XML, 2=JSON)
+     * @param mode   output mode (0=HTML, 1=XML, 2=JSON)
      */
     public static void writeFooter(PrintWriter writer, int mode) {
         if (mode == 0) {
@@ -655,16 +659,12 @@ public class StatusTransformer {
                     writer.write("0");
                 }
                 writer.write("\"");
-                writer.write(" remoteAddr=\"" +
-                        
Escape.xml(String.valueOf(mBeanServer.getAttribute(pName, "remoteAddr"))) + 
"\"");
-                writer.write(" virtualHost=\"" +
-                        
Escape.xml(String.valueOf(mBeanServer.getAttribute(pName, "virtualHost"))) + 
"\"");
+                writer.write(" remoteAddr=\"" + 
Escape.xml(mBeanServer.getAttribute(pName, "remoteAddr")) + "\"");
+                writer.write(" virtualHost=\"" + 
Escape.xml(mBeanServer.getAttribute(pName, "virtualHost")) + "\"");
 
                 if (showRequest) {
-                    writer.write(
-                            " method=\"" + 
Escape.xml(String.valueOf(mBeanServer.getAttribute(pName, "method"))) + "\"");
-                    writer.write(" currentUri=\"" +
-                            
Escape.xml(String.valueOf(mBeanServer.getAttribute(pName, "currentUri"))) + 
"\"");
+                    writer.write(" method=\"" + 
Escape.xml(mBeanServer.getAttribute(pName, "method")) + "\"");
+                    writer.write(" currentUri=\"" + 
Escape.xml(mBeanServer.getAttribute(pName, "currentUri")) + "\"");
 
                     String queryString = (String) 
mBeanServer.getAttribute(pName, "currentQueryString");
                     if (queryString != null && !queryString.isEmpty()) {
@@ -672,8 +672,7 @@ public class StatusTransformer {
                     } else {
                         writer.write(" currentQueryString=\"&#63;\"");
                     }
-                    writer.write(" protocol=\"" +
-                            
Escape.xml(String.valueOf(mBeanServer.getAttribute(pName, "protocol"))) + "\"");
+                    writer.write(" protocol=\"" + 
Escape.xml(mBeanServer.getAttribute(pName, "protocol")) + "\"");
                 } else {
                     writer.write(" method=\"&#63;\"");
                     writer.write(" currentUri=\"&#63;\"");
diff --git a/java/org/apache/tomcat/util/security/Escape.java 
b/java/org/apache/tomcat/util/security/Escape.java
index 5bdf8b8276..f2d79b7f7e 100644
--- a/java/org/apache/tomcat/util/security/Escape.java
+++ b/java/org/apache/tomcat/util/security/Escape.java
@@ -85,6 +85,21 @@ public class Escape {
     }
 
 
+    /**
+     * Escape content for use in XML.
+     *
+     * @param content The content to escape
+     *
+     * @return The escaped content converted to String or {@code &#63;} if the 
content was {@code null}
+     */
+    public static String xml(Object content) {
+        if (content == null) {
+            return "&#63;";
+        }
+        return xml(null, false, String.valueOf(content));
+    }
+
+
     /**
      * Escape content for use in XML.
      *


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

Reply via email to