mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
403 for static directory listing, closes #740
This commit is contained in:
parent
25014ca25e
commit
89c4ddd482
2 changed files with 9 additions and 0 deletions
|
|
@ -328,6 +328,9 @@ def asgi_static(root_path, chunk_size=4096, headers=None, content_type=None):
|
|||
except FileNotFoundError:
|
||||
await asgi_send_html(send, "404", 404)
|
||||
return
|
||||
if full_path.is_dir():
|
||||
await asgi_send_html(send, "403: Directory listing is not allowed", 403)
|
||||
return
|
||||
# Ensure full_path is within root_path to avoid weird "../" tricks
|
||||
try:
|
||||
full_path.relative_to(root_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue