Skip to content

Commit

Permalink
fix : path traversal StaticBucketRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
AssahBismarkabah committed Sep 19, 2024
1 parent 32d36bc commit 16f453a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public String resourceKey(AbsoluteLocation resource) {
UnaryOperator<String> trimStartingSlash = str -> str.replaceFirst("^/", "");

String resourcePath = trimStartingSlash.apply(resource.location().getRawPath());
if (bucketName == null || "".equals(bucketName) || !resourcePath.contains(bucketName)) {
if (bucketName == null || "".equals(bucketName) || !resourcePath.startsWith(bucketName)) {
return resourcePath;
}

return trimStartingSlash.apply(resourcePath.substring(resourcePath.indexOf(bucketName) + bucketName.length()));
return trimStartingSlash.apply(resourcePath.substring(bucketName.length()));
}
}

0 comments on commit 16f453a

Please sign in to comment.