issue_comments: 738213342
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/simonw/datasette/issues/1124#issuecomment-738213342 | https://api.github.com/repos/simonw/datasette/issues/1124 | 738213342 | MDEyOklzc3VlQ29tbWVudDczODIxMzM0Mg== | 9599 | 2020-12-03T18:46:22Z | 2020-12-03T21:40:51Z | OWNER | I replaced that function with this code: ```python def asgi_static(root_path, chunk_size=4096, headers=None, content_type=None): async def inner_static(request, send): path = request.scope["url_route"]["kwargs"]["path"] print("path =", path) try: full_path = (Path(root_path) / path).resolve().absolute() except FileNotFoundError as e: print("FileNotFoundError:", e) 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: print("full_path={}, root_path={}".format(full_path, root_path)) full_path.relative_to(root_path) except ValueError as e: print(" ValueError:", e) await asgi_send_html(send, "404", 404) return try: await asgi_send_file(send, full_path, chunk_size=chunk_size) except FileNotFoundError: await asgi_send_html(send, "404", 404) return
The output shows me what the bug is:
One is |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
756439516 |