Skip to content

Commit 46bbda7

Browse files
committed
Fix: Preventing only .. in path and allowing .
1 parent 9031248 commit 46bbda7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/httpserver_templates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
def directory_listing(request: Request):
3030
path = request.query_params.get("path") or ""
3131

32-
# Remove .. and . from path
33-
path = re.sub(r"\/(\.\.|\.)\/|\/(\.\.|\.)|(\.\.|\.)\/", "/", path).strip("/")
32+
# Preventing path travelsal by removing all ../ from path
33+
path = re.sub(r"\/(\.\.)\/|\/(\.\.)|(\.\.)\/", "/", path).strip("/")
3434

3535
if path:
3636
is_file = (

0 commit comments

Comments
 (0)