Nullability fine-tuning based on IntelliJ IDEA 2018.3 inspection

Issue: SPR-15540
This commit is contained in:
Juergen Hoeller
2018-11-22 16:12:38 +01:00
parent b1b28d4641
commit bf272b0b21
14 changed files with 66 additions and 66 deletions

View File

@@ -113,11 +113,8 @@ class PathResourceLookupFunction implements Function<ServerRequest, Mono<Resourc
return true;
}
}
if (path.contains("")) {
path = StringUtils.cleanPath(path);
if (path.contains("../")) {
return true;
}
if (path.contains("..") && StringUtils.cleanPath(path).contains("../")) {
return true;
}
return false;
}

View File

@@ -494,22 +494,19 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
*/
protected boolean isInvalidPath(String path) {
if (path.contains("WEB-INF") || path.contains("META-INF")) {
logger.warn("Path contains \"WEB-INF\" or \"META-INF\".");
logger.warn("Path with \"WEB-INF\" or \"META-INF\": [" + path + "]");
return true;
}
if (path.contains(":/")) {
String relativePath = (path.charAt(0) == '/' ? path.substring(1) : path);
if (ResourceUtils.isUrl(relativePath) || relativePath.startsWith("url:")) {
logger.warn("Path represents URL or has \"url:\" prefix.");
logger.warn("Path represents URL or has \"url:\" prefix: [" + path + "]");
return true;
}
}
if (path.contains("..")) {
path = StringUtils.cleanPath(path);
if (path.contains("../")) {
logger.warn("Path contains \"../\" after call to StringUtils#cleanPath.");
return true;
}
if (path.contains("..") && StringUtils.cleanPath(path).contains("../")) {
logger.warn("Path contains \"../\" after call to StringUtils#cleanPath: [" + path + "]");
return true;
}
return false;
}