Skip to content

Commit 70c44b8

Browse files
authored
Remove path traversal check in StaticFileHandler
Removed path traversal check for static file handling.
1 parent bdecdb4 commit 70c44b8

1 file changed

Lines changed: 0 additions & 7 deletions

File tree

src/main/java/org/example/StaticFileHandler.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ private void handleGetRequest(HttpRequest request, HttpResponseBuilder response)
5555

5656
// Path traversal check
5757

58-
File root = new File(WEB_ROOT).getCanonicalFile();
59-
File file = new File(root, uri).getCanonicalFile();
60-
61-
if (!file.toPath().startsWith(root.toPath())) {
62-
fileBytes = "403 Forbidden".getBytes(java.nio.charset.StandardCharsets.UTF_8);
63-
statusCode = SC_FORBIDDEN;
64-
return;
6558

6659
File root;
6760
File file;

0 commit comments

Comments
 (0)