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

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


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 21afa47bbd Allow for absolute host names in Mapper
21afa47bbd is described below

commit 21afa47bbd7c61822e65927ba63198f64721ac2a
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Oct 26 12:14:53 2026 +0000

    Allow for absolute host names in Mapper
---
 java/org/apache/catalina/mapper/Mapper.java | 49 ++++++++++++++++++-----------
 1 file changed, 31 insertions(+), 18 deletions(-)

diff --git a/java/org/apache/catalina/mapper/Mapper.java 
b/java/org/apache/catalina/mapper/Mapper.java
index ec6f1093da..7c792864ad 100644
--- a/java/org/apache/catalina/mapper/Mapper.java
+++ b/java/org/apache/catalina/mapper/Mapper.java
@@ -736,30 +736,43 @@ public final class Mapper {
         }
 
         // Virtual host mapping
-        MappedHost[] hosts = this.hosts;
-        MappedHost mappedHost = exactFindIgnoreCase(hosts, host);
-        if (mappedHost == null) {
-            // Note: Internally, the Mapper does not use the leading * on a
-            // wildcard host. This is to allow this shortcut.
-            int firstDot = host.indexOf('.');
-            if (firstDot > -1) {
-                int start = host.getStart();
-                try {
-                    host.setStart(firstDot + start);
-                    mappedHost = exactFindIgnoreCase(hosts, host);
-                } finally {
-                    // Make absolutely sure this gets reset
-                    host.setStart(start);
-                }
+        boolean trailingPeriodRemoved = false;
+        MappedHost mappedHost = null;
+        try {
+            if (host.charAt(host.length() - 1)  == '.') {
+                host.setEnd(host.getEnd() - 1);
+                trailingPeriodRemoved = true;
             }
+            MappedHost[] hosts = this.hosts;
+            mappedHost = exactFindIgnoreCase(hosts, host);
             if (mappedHost == null) {
-                mappedHost = defaultHost;
+                // Note: Internally, the Mapper does not use the leading * on a
+                // wildcard host. This is to allow this shortcut.
+                int firstDot = host.indexOf('.');
+                if (firstDot > -1) {
+                    int start = host.getStart();
+                    try {
+                        host.setStart(firstDot + start);
+                        mappedHost = exactFindIgnoreCase(hosts, host);
+                    } finally {
+                        // Make absolutely sure this gets reset
+                        host.setStart(start);
+                    }
+                }
                 if (mappedHost == null) {
-                    return;
+                    mappedHost = defaultHost;
+                    if (mappedHost == null) {
+                        return;
+                    }
                 }
             }
+            mappingData.host = mappedHost.object;
+        } finally {
+            // Make absolutely sure this gets reset if required
+            if (trailingPeriodRemoved) {
+                host.setEnd(host.getEnd() + 1);
+            }
         }
-        mappingData.host = mappedHost.object;
 
         if (uri.isNull()) {
             // Can't map context or wrapper without a uri


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

Reply via email to