parent
7c2c4d7c9a
commit
fb7890d739
|
@ -148,20 +148,28 @@ class PathResourceLookupFunction implements Function<ServerRequest, Mono<Resourc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String normalizePath(String path) {
|
private static String normalizePath(String path) {
|
||||||
if (path.contains("%")) {
|
String result = path;
|
||||||
try {
|
if (result.contains("%")) {
|
||||||
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
|
result = decode(result);
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
if (result.contains("../")) {
|
||||||
return "";
|
return StringUtils.cleanPath(result);
|
||||||
}
|
|
||||||
if (path.contains("../")) {
|
|
||||||
path = StringUtils.cleanPath(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String decode(String path) {
|
||||||
|
try {
|
||||||
|
return URLDecoder.decode(path, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isInvalidPath(String path) {
|
private boolean isInvalidPath(String path) {
|
||||||
if (path.contains("WEB-INF") || path.contains("META-INF")) {
|
if (path.contains("WEB-INF") || path.contains("META-INF")) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -567,20 +567,28 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String normalizePath(String path) {
|
private static String normalizePath(String path) {
|
||||||
if (path.contains("%")) {
|
String result = path;
|
||||||
try {
|
if (result.contains("%")) {
|
||||||
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
|
result = decode(result);
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
if (result.contains("../")) {
|
||||||
return "";
|
return StringUtils.cleanPath(result);
|
||||||
}
|
|
||||||
if (path.contains("../")) {
|
|
||||||
path = StringUtils.cleanPath(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String decode(String path) {
|
||||||
|
try {
|
||||||
|
return URLDecoder.decode(path, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the given path contains invalid escape sequences.
|
* Check whether the given path contains invalid escape sequences.
|
||||||
* @param path the path to validate
|
* @param path the path to validate
|
||||||
|
|
|
@ -149,20 +149,28 @@ class PathResourceLookupFunction implements Function<ServerRequest, Optional<Res
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String normalizePath(String path) {
|
private static String normalizePath(String path) {
|
||||||
if (path.contains("%")) {
|
String result = path;
|
||||||
try {
|
if (result.contains("%")) {
|
||||||
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
|
result = decode(result);
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
if (result.contains("../")) {
|
||||||
return "";
|
return StringUtils.cleanPath(result);
|
||||||
}
|
|
||||||
if (path.contains("../")) {
|
|
||||||
path = StringUtils.cleanPath(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String decode(String path) {
|
||||||
|
try {
|
||||||
|
return URLDecoder.decode(path, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isInvalidPath(String path) {
|
private boolean isInvalidPath(String path) {
|
||||||
if (path.contains("WEB-INF") || path.contains("META-INF")) {
|
if (path.contains("WEB-INF") || path.contains("META-INF")) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -726,20 +726,28 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String normalizePath(String path) {
|
private static String normalizePath(String path) {
|
||||||
if (path.contains("%")) {
|
String result = path;
|
||||||
try {
|
if (result.contains("%")) {
|
||||||
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
|
result = decode(result);
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
if (result.contains("../")) {
|
||||||
return "";
|
return StringUtils.cleanPath(result);
|
||||||
}
|
|
||||||
if (path.contains("../")) {
|
|
||||||
path = StringUtils.cleanPath(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String decode(String path) {
|
||||||
|
try {
|
||||||
|
return URLDecoder.decode(path, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the given path contains invalid escape sequences.
|
* Check whether the given path contains invalid escape sequences.
|
||||||
* @param path the path to validate
|
* @param path the path to validate
|
||||||
|
|
Loading…
Reference in New Issue