Skip to content

Commit 012c56a

Browse files
committed
Avoid pattern misdetection in Tomcat "war:" URL separator
Issue: SPR-15332
1 parent f6e2c58 commit 012c56a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,10 @@ public Resource[] getResources(String locationPattern) throws IOException {
284284
}
285285
}
286286
else {
287-
// Only look for a pattern after a prefix here
288-
// (to not get fooled by a pattern symbol in a strange prefix).
289-
int prefixEnd = locationPattern.indexOf(":") + 1;
287+
// Generally only look for a pattern after a prefix here,
288+
// and on Tomcat only after the "*/" separator for its "war:" protocol.
289+
int prefixEnd = (locationPattern.startsWith("war:") ? locationPattern.indexOf("*/") + 1 :
290+
locationPattern.indexOf(":") + 1);
290291
if (getPathMatcher().isPattern(locationPattern.substring(prefixEnd))) {
291292
// a file pattern
292293
return findPathMatchingResources(locationPattern);

0 commit comments

Comments
 (0)