Polishing

This commit is contained in:
Juergen Hoeller
2018-11-22 18:21:56 +01:00
parent bf272b0b21
commit ae8f680d2e
6 changed files with 25 additions and 12 deletions

View File

@@ -630,18 +630,24 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
*/
protected boolean isInvalidPath(String path) {
if (path.contains("WEB-INF") || path.contains("META-INF")) {
logger.warn("Path with \"WEB-INF\" or \"META-INF\": [" + path + "]");
if (logger.isWarnEnabled()) {
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: [" + path + "]");
if (logger.isWarnEnabled()) {
logger.warn("Path represents URL or has \"url:\" prefix: [" + path + "]");
}
return true;
}
}
if (path.contains("..") && StringUtils.cleanPath(path).contains("../")) {
logger.warn("Invalid Path contains \"../\" after call to StringUtils#cleanPath: [" + path + "]");
if (logger.isWarnEnabled()) {
logger.warn("Path contains \"../\" after call to StringUtils#cleanPath: [" + path + "]");
}
return true;
}
return false;