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
commit 5cbc3bafeb6648dba33540a7c85c1f6dd2a3f183 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 65589455f4..79f158824d 100644 --- a/java/org/apache/catalina/mapper/Mapper.java +++ b/java/org/apache/catalina/mapper/Mapper.java @@ -747,30 +747,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]
