Skip to content

Commit

Permalink
Enforce cleaned URL for root resource from ClassLoader
Browse files Browse the repository at this point in the history
Closes gh-32828
  • Loading branch information
jhoeller committed May 15, 2024
1 parent 70886e3 commit 2270df5
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,17 @@ protected Resource convertClassLoaderURL(URL url) {
}
}
else {
String urlString = url.toString();
String cleanedPath = StringUtils.cleanPath(urlString);
if (!cleanedPath.equals(urlString)) {
// Prefer cleaned URL, aligned with UrlResource#createRelative(String)
try {
return new UrlResource(ResourceUtils.toURI(cleanedPath));
}
catch (URISyntaxException | MalformedURLException ex) {
// Fallback to regular URL construction below...
}
}
return new UrlResource(url);
}
}
Expand Down

0 comments on commit 2270df5

Please sign in to comment.