parent
7c2c4d7c9a
commit
fb7890d739
|
@ -148,18 +148,26 @@ 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;
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
|
}
|
||||||
|
if (result.contains("../")) {
|
||||||
|
return StringUtils.cleanPath(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String decode(String path) {
|
||||||
try {
|
try {
|
||||||
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
|
return URLDecoder.decode(path, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (path.contains("../")) {
|
|
||||||
path = StringUtils.cleanPath(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInvalidPath(String path) {
|
private boolean isInvalidPath(String path) {
|
||||||
|
|
|
@ -567,18 +567,26 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String normalizePath(String path) {
|
private static String normalizePath(String path) {
|
||||||
if (path.contains("%")) {
|
String result = path;
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
|
}
|
||||||
|
if (result.contains("../")) {
|
||||||
|
return StringUtils.cleanPath(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String decode(String path) {
|
||||||
try {
|
try {
|
||||||
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
|
return URLDecoder.decode(path, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (path.contains("../")) {
|
|
||||||
path = StringUtils.cleanPath(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -149,18 +149,26 @@ 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;
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
|
}
|
||||||
|
if (result.contains("../")) {
|
||||||
|
return StringUtils.cleanPath(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String decode(String path) {
|
||||||
try {
|
try {
|
||||||
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
|
return URLDecoder.decode(path, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (path.contains("../")) {
|
|
||||||
path = StringUtils.cleanPath(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInvalidPath(String path) {
|
private boolean isInvalidPath(String path) {
|
||||||
|
|
|
@ -726,18 +726,26 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String normalizePath(String path) {
|
private static String normalizePath(String path) {
|
||||||
if (path.contains("%")) {
|
String result = path;
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
|
if (result.contains("%")) {
|
||||||
|
result = decode(result);
|
||||||
|
}
|
||||||
|
if (result.contains("../")) {
|
||||||
|
return StringUtils.cleanPath(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String decode(String path) {
|
||||||
try {
|
try {
|
||||||
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
|
return URLDecoder.decode(path, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (path.contains("../")) {
|
|
||||||
path = StringUtils.cleanPath(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue