Skip to content

Commit

Permalink
Merge pull request #12 from YasasRangika/yasas-5.3.39-wso2vx
Browse files Browse the repository at this point in the history
Fix build issues
  • Loading branch information
YasasRangika authored Nov 26, 2024
2 parents 7fa259d + 4fbad45 commit d8dc331
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.function.Function;
Expand Down Expand Up @@ -169,7 +170,7 @@ private boolean isInvalidEncodedInputPath(String path) {
if (path.contains("%")) {
try {
// Use URLDecoder (vs UriUtils) to preserve potentially decoded UTF-8 chars
String decodedPath = URLDecoder.decode(path, StandardCharsets.UTF_8);
String decodedPath = URLDecoder.decode(path, "UTF-8");
if (isInvalidPath(decodedPath)) {
return true;
}
Expand All @@ -178,7 +179,7 @@ private boolean isInvalidEncodedInputPath(String path) {
return true;
}
}
catch (IllegalArgumentException ex) {
catch (IllegalArgumentException | UnsupportedEncodingException ex) {
// May not be possible to decode...
}
}
Expand Down Expand Up @@ -217,12 +218,12 @@ private boolean isInvalidEncodedResourcePath(String resourcePath) {
if (resourcePath.contains("%")) {
// Use URLDecoder (vs UriUtils) to preserve potentially decoded UTF-8 chars...
try {
String decodedPath = URLDecoder.decode(resourcePath, StandardCharsets.UTF_8);
String decodedPath = URLDecoder.decode(resourcePath, "UTF-8");
if (decodedPath.contains("../") || decodedPath.contains("..\\")) {
return true;
}
}
catch (IllegalArgumentException ex) {
catch (IllegalArgumentException | UnsupportedEncodingException ex) {
// May not be possible to decode...
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
import java.util.function.Function;

Expand Down Expand Up @@ -72,7 +72,7 @@ public Optional<Resource> apply(ServerRequest request) {
return Optional.empty();
}
if (!(this.location instanceof UrlResource)) {
path = UriUtils.decode(path, StandardCharsets.UTF_8);
path = UriUtils.decode(path, "UTF-8");
}

try {
Expand Down Expand Up @@ -161,7 +161,7 @@ private boolean isInvalidEncodedInputPath(String path) {
if (path.contains("%")) {
try {
// Use URLDecoder (vs UriUtils) to preserve potentially decoded UTF-8 chars
String decodedPath = URLDecoder.decode(path, StandardCharsets.UTF_8);
String decodedPath = URLDecoder.decode(path, "UTF-8");
if (isInvalidPath(decodedPath)) {
return true;
}
Expand All @@ -170,7 +170,7 @@ private boolean isInvalidEncodedInputPath(String path) {
return true;
}
}
catch (IllegalArgumentException ex) {
catch (IllegalArgumentException | UnsupportedEncodingException ex) {
// May not be possible to decode...
}
}
Expand All @@ -193,7 +193,8 @@ else if (resource instanceof ClassPathResource) {
resourcePath = ((ClassPathResource) resource).getPath();
locationPath = StringUtils.cleanPath(((ClassPathResource) this.location).getPath());
}
else if (resource instanceof ServletContextResource servletContextResource) {
else if (resource instanceof ServletContextResource) {
ServletContextResource servletContextResource = (ServletContextResource) resource;
resourcePath = servletContextResource.getPath();
locationPath = StringUtils.cleanPath(((ServletContextResource) this.location).getPath());
}
Expand All @@ -213,12 +214,12 @@ private boolean isInvalidEncodedResourcePath(String resourcePath) {
if (resourcePath.contains("%")) {
// Use URLDecoder (vs UriUtils) to preserve potentially decoded UTF-8 chars...
try {
String decodedPath = URLDecoder.decode(resourcePath, StandardCharsets.UTF_8);
String decodedPath = URLDecoder.decode(resourcePath, "UTF-8");
if (decodedPath.contains("../") || decodedPath.contains("..\\")) {
return true;
}
}
catch (IllegalArgumentException ex) {
catch (IllegalArgumentException | UnsupportedEncodingException ex) {
// May not be possible to decode...
}
}
Expand Down

0 comments on commit d8dc331

Please sign in to comment.