-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Closed as not planned
Closed as not planned
Copy link
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by another
Description
Hi,
after we migrated from Spring Boot 3.1.8 to 3.2.2, our applications installed in path containing empty space suddenly stoped working.
The problem seems to be in new "nested jar" mechanism used to resource locating in the jar/war file.
I tried to prepare simple test which fails in 3.2.2:
@BeforeAll
static void setUpClass() {
Handlers.register();
}
@Test
void testNestedJarPathWithSpaceEncoded() throws Exception {
var nestedJarUrl = new URL("jar:nested:/C:/Program%20Files/app.jar/!BOOT-INF/classes/!/static/app/nested.jar");
var nestedJarConnection = nestedJarUrl.openConnection();
assertThat(nestedJarConnection.getLastModified(), greaterThan(0L));
}
This works fine in 3.1.8:
@BeforeAll
static void setUpClass() {
JarFile.registerUrlProtocolHandler();
}
@Test
void testNestedJarPathWithSpaceEncoded() throws Exception {
var jarUrl = new URL("jar:file:/C:/Program%20Files/app.jar/!/BOOT-INF/classes/!/static/app/nested.jar");
var jarConnection = jarUrl.openConnection();
assertThat(jarConnection.getLastModified(), greaterThan(0L));
}
I think that the problem is in implementation of the NestedUrlConnection class:
private NestedLocation parseNestedLocation(URL url) throws MalformedURLException {
try {
return NestedLocation.parse(url.getPath());
}
catch (IllegalArgumentException ex) {
throw new MalformedURLException(ex.getMessage());
}
}
Path should be decoded before passing it to NestedLocation.parse method. The URL passed to static method NestedLocation.fromUrl is also decoded before passed to NestedLocation.parse method.
So I would propose this change:
private NestedLocation parseNestedLocation(URL url) throws MalformedURLException {
try {
return NestedLocation.parse(UrlDecoder.decode(url.getPath()));
}
catch (IllegalArgumentException ex) {
throw new MalformedURLException(ex.getMessage());
}
}
Will create PR for that If you do not mind.
Metadata
Metadata
Assignees
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by another