Fix absolute paths when transforming resources
Prior to this commit, `ResourceTransformerSupport.toAbsolutePath` would call `StringUtils.applyRelativePath` in all cases. But this implementation is prepending the given path even if the relative path starts with `"/"`. This commit skips the entire operation if the given path is absolute, i.e. it starts with `"/"`. Issue: SPR-17432
This commit is contained in:
@@ -96,7 +96,7 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer
|
||||
*/
|
||||
protected String toAbsolutePath(String path, ServerWebExchange exchange) {
|
||||
String requestPath = exchange.getRequest().getURI().getPath();
|
||||
String absolutePath = StringUtils.applyRelativePath(requestPath, path);
|
||||
String absolutePath = path.startsWith("/") ? path : StringUtils.applyRelativePath(requestPath, path);
|
||||
return StringUtils.cleanPath(absolutePath);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user