Skip to content

Commit 727cbb1

Browse files
committed
Minor bug fix
1 parent 48e47be commit 727cbb1

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/express/filter/FilterImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public FilterImpl(String requestMethod, String context, HttpRequest httpRequest)
4040
}
4141

4242
public void setRoot(String root) {
43-
if (root == null || root.length() == 0)
43+
if (root == null || root.isEmpty())
4444
return;
4545

4646
if (root.charAt(0) != '/')

src/express/http/response/Response.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ public boolean isClosed() {
226226
return this.isClose;
227227
}
228228

229-
230229
private void sendHeaders() {
231230
try {
232231

src/express/middleware/FileProvider.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,18 @@ public void handle(Request req, Response res) {
5454
String name = reqFile.getFileName().toString();
5555

5656
try {
57-
Optional<Path> founded = Files.walk(reqFile.getParent()).filter(sub -> getBaseName(sub).equals(name)).findFirst();
57+
Path parent = reqFile.getParent();
5858

59-
if (founded.isPresent())
60-
reqFile = founded.get();
59+
// Check if reading is allowed
60+
if (Files.isReadable(parent)) {
6161

62+
Optional<Path> founded = Files.walk(parent).filter(sub -> getBaseName(sub).equals(name)).findFirst();
63+
64+
if (founded.isPresent())
65+
reqFile = founded.get();
66+
}
6267
} catch (IOException e) {
63-
this.LOGGER.log(Level.WARNING, "Cannot walg file tree.", e);
68+
this.LOGGER.log(Level.WARNING, "Cannot walk file tree.", e);
6469
}
6570
}
6671

0 commit comments

Comments
 (0)