Do not support relative static resource paths

Closes gh-33687
This commit is contained in:
rstoyanchev
2024-10-14 15:50:44 +01:00
parent e191c34078
commit 1a0b577bfc
4 changed files with 4 additions and 2 deletions

View File

@@ -140,7 +140,7 @@ public abstract class ResourceHandlerUtils {
return true;
}
}
if (path.contains("..") && StringUtils.cleanPath(path).contains("../")) {
if (path.contains("../")) {
if (logger.isWarnEnabled()) {
logger.warn(LogFormatUtils.formatValue(
"Path contains \"../\" after call to StringUtils#cleanPath: [" + path + "]", -1, true));

View File

@@ -687,6 +687,7 @@ class ResourceWebHandlerTests {
testResolvePathWithTraversal(method, "../testsecret/secret.txt");
testResolvePathWithTraversal(method, "test/../../testsecret/secret.txt");
testResolvePathWithTraversal(method, "/testsecret/test/../secret.txt");
testResolvePathWithTraversal(method, ":/../../testsecret/secret.txt");
location = new UrlResource(getClass().getResource("./test/"));