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

markt-asf 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 9e035e8d06 Follow-on to "Allow re-adding a host that was previously 
removed..."
9e035e8d06 is described below

commit 9e035e8d069184507363252d3d105d4de61a0885
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Oct 7 15:54:56 2026 +0100

    Follow-on to "Allow re-adding a host that was previously removed..."
---
 .../catalina/manager/host/HostManagerServlet.java  | 24 +++++++++++++++++++++-
 webapps/docs/changelog.xml                         |  4 ++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/manager/host/HostManagerServlet.java 
b/java/org/apache/catalina/manager/host/HostManagerServlet.java
index d1d0de5c04..4f421dcf52 100644
--- a/java/org/apache/catalina/manager/host/HostManagerServlet.java
+++ b/java/org/apache/catalina/manager/host/HostManagerServlet.java
@@ -25,6 +25,7 @@ import java.lang.management.ManagementFactory;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
+import java.util.Locale;
 import java.util.StringTokenizer;
 
 import javax.management.InstanceNotFoundException;
@@ -309,7 +310,13 @@ public class HostManagerServlet extends HttpServlet 
implements ContainerServlet
     }
 
 
-    // -------------------------------------------------------- Private Methods
+    private static String normalizeHostName(String hostName) {
+        if (hostName == null) {
+            return null;
+        } else {
+            return hostName.toLowerCase(Locale.ENGLISH);
+        }
+    }
 
 
     /**
@@ -340,6 +347,9 @@ public class HostManagerServlet extends HttpServlet 
implements ContainerServlet
             return;
         }
 
+        // Normalize host name before it is used
+        name = normalizeHostName(name);
+
         // Check if host already exists
         if (engine.findChild(name) != null) {
             
writer.println(smClient.getString("hostManagerServlet.alreadyHost", name));
@@ -456,6 +466,9 @@ public class HostManagerServlet extends HttpServlet 
implements ContainerServlet
             return;
         }
 
+        // Normalize host name before it is used
+        name = normalizeHostName(name);
+
         // Check if host exists
         if (engine.findChild(name) == null) {
             writer.println(smClient.getString("hostManagerServlet.noHost", 
name));
@@ -534,6 +547,9 @@ public class HostManagerServlet extends HttpServlet 
implements ContainerServlet
             return;
         }
 
+        // Normalize host name before it is used
+        name = normalizeHostName(name);
+
         Container host = engine.findChild(name);
 
         // Check if host exists
@@ -585,6 +601,9 @@ public class HostManagerServlet extends HttpServlet 
implements ContainerServlet
             return;
         }
 
+        // Normalize host name before it is used
+        name = normalizeHostName(name);
+
         Container host = engine.findChild(name);
 
         // Check if host exists
@@ -676,6 +695,9 @@ public class HostManagerServlet extends HttpServlet 
implements ContainerServlet
      * @return the config base for the host
      */
     protected File getConfigBase(String hostName, PrintWriter writer, 
StringManager smClient) {
+        // Normalize host name before it is used
+        hostName = normalizeHostName(hostName);
+
         File configBase = new File(context.getCatalinaBase(), "conf");
         if (!configBase.exists()) {
             return null;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index a0b69356cb..51e125ce6c 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -383,6 +383,10 @@
         Tapestry attributes, used for locale session sorting. (remm)
       </update>
       <!-- Entries for backport and removal before 12.0.0-M1 below this line 
-->
+      <fix>
+        Host Manager: Host names are now always converted to lower case before
+        use. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Tribes">


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

Reply via email to