Use encoded version of path for jar URLs

Update `JarUrl` so that the encoded version of the path is used.
This allows jars to placed in directories with `#` or `!` in the
name.

Fixes gh-38660
This commit is contained in:
Phillip Webb
2023-12-06 15:57:50 -08:00
parent 847daf484c
commit 359a6cb5bb
3 changed files with 27 additions and 1 deletions

View File

@@ -79,7 +79,7 @@ public final class JarUrl {
}
private static String getJarReference(File file, String nestedEntryName) {
String jarFilePath = file.toURI().getPath();
String jarFilePath = file.toURI().getRawPath().replace("!", "%21");
return (nestedEntryName != null) ? "nested:" + jarFilePath + "/!" + nestedEntryName : "file:" + jarFilePath;
}