Skip to content

Commit 4e720e8

Browse files
committed
Encode hash symbol in jar file path (for compatibility with JDK 11+)
Closes gh-26104 (cherry picked from commit b297236)
1 parent fdab75a commit 4e720e8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ protected void addClassPathManifestEntries(Set<Resource> result) {
432432
// Possibly "c:" drive prefix on Windows, to be upper-cased for proper duplicate detection
433433
filePath = StringUtils.capitalize(filePath);
434434
}
435+
// # can appear in directories/filenames, java.net.URL should not treat it as a fragment
436+
filePath = StringUtils.replace(filePath, "#", "%23");
437+
// Build URL that points to the root of the jar file
435438
UrlResource jarResource = new UrlResource(ResourceUtils.JAR_URL_PREFIX +
436439
ResourceUtils.FILE_URL_PREFIX + filePath + ResourceUtils.JAR_URL_SEPARATOR);
437440
// Potentially overlapping with URLClassLoader.getURLs() result above!

0 commit comments

Comments
 (0)