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 5ac5e68a0e Follow-up to URL decoding fix
5ac5e68a0e is described below
commit 5ac5e68a0ea32a391cd28a91d9bac069a28ec9ec
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Jun 15 16:29:04 2026 +0100
Follow-up to URL decoding fix
---
.../catalina/core/ApplicationServletRegistration.java | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/java/org/apache/catalina/core/ApplicationServletRegistration.java
b/java/org/apache/catalina/core/ApplicationServletRegistration.java
index 3b758efabb..3433932abb 100644
--- a/java/org/apache/catalina/core/ApplicationServletRegistration.java
+++ b/java/org/apache/catalina/core/ApplicationServletRegistration.java
@@ -173,8 +173,6 @@ public class ApplicationServletRegistration implements
ServletRegistration.Dynam
return Collections.emptySet();
}
- Set<String> conflicts = new HashSet<>();
-
String[] decodedUrlPatterns = new String[urlPatterns.length];
for (int i = 0; i < urlPatterns.length; i++) {
if (urlPatterns[i] == null) {
@@ -183,14 +181,20 @@ public class ApplicationServletRegistration implements
ServletRegistration.Dynam
decodedUrlPatterns[i] = UDecoder.URLDecode(urlPatterns[i],
StandardCharsets.UTF_8);
}
+ Set<String> conflicts = new HashSet<>();
+ Set<String> overrides = new HashSet<>();
+
for (int i = 0; i < decodedUrlPatterns.length; i++) {
String wrapperName =
context.findServletMapping(decodedUrlPatterns[i]);
if (wrapperName != null) {
Wrapper wrapper = (Wrapper) context.findChild(wrapperName);
if (wrapper.isOverridable()) {
- // Some Wrappers (from global and host web.xml) may be
- // overridden rather than generating a conflict
- context.removeServletMapping(decodedUrlPatterns[i]);
+ /*
+ * Some Wrappers (from global and host web.xml) may be
overridden rather than generating a conflict.
+ * Changes as a result of this method should be all or
nothing so note the overrides until the check
+ * for conflicts has completed.
+ */
+ overrides.add(decodedUrlPatterns[i]);
} else {
conflicts.add(urlPatterns[i]);
}
@@ -201,6 +205,9 @@ public class ApplicationServletRegistration implements
ServletRegistration.Dynam
return conflicts;
}
+ // No conflicts, remove the mappings that are about to be overridden
+ overrides.forEach(p -> context.removeServletMapping(p));
+
for (String urlPattern : decodedUrlPatterns) {
context.addServletMappingDecoded(urlPattern, wrapper.getName());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]