@ -148,20 +148,28 @@ class PathResourceLookupFunction implements Function<ServerRequest, Mono<Resourc
@@ -148,20 +148,28 @@ class PathResourceLookupFunction implements Function<ServerRequest, Mono<Resourc
}
private static String normalizePath ( String path ) {
if ( path . contains ( "%" ) ) {
try {
path = URLDecoder . decode ( path , StandardCharsets . UTF_8 ) ;
String result = path ;
if ( result . contains ( "%" ) ) {
result = decode ( result ) ;
if ( result . contains ( "%" ) ) {
result = decode ( result ) ;
}
catch ( Exception ex ) {
return "" ;
}
if ( path . contains ( "../" ) ) {
path = StringUtils . cleanPath ( path ) ;
if ( result . contains ( "../" ) ) {
return StringUtils . cleanPath ( result ) ;
}
}
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 ) {
if ( path . contains ( "WEB-INF" ) | | path . contains ( "META-INF" ) ) {
return true ;