Skip to content

Commit 74d3044

Browse files
committed
Merge pull request #25415 from thenx-wei/master
* gh-25415: Simplify PathResourceLookupFunction
2 parents 88394bf + 24b1caf commit 74d3044

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/function/PathResourceLookupFunction.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ private boolean isInvalidPath(String path) {
110110
return true;
111111
}
112112
}
113-
if (path.contains("..") && StringUtils.cleanPath(path).contains("../")) {
114-
return true;
115-
}
116-
return false;
113+
return path.contains("..") && StringUtils.cleanPath(path).contains("../");
117114
}
118115

119116
private boolean isResourceUnderLocation(Resource resource) throws IOException {
@@ -144,10 +141,8 @@ else if (resource instanceof ClassPathResource) {
144141
if (!resourcePath.startsWith(locationPath)) {
145142
return false;
146143
}
147-
if (resourcePath.contains("%") && StringUtils.uriDecode(resourcePath, StandardCharsets.UTF_8).contains("../")) {
148-
return false;
149-
}
150-
return true;
144+
return !resourcePath.contains("%") ||
145+
!StringUtils.uriDecode(resourcePath, StandardCharsets.UTF_8).contains("../");
151146
}
152147

153148

0 commit comments

Comments
 (0)