github
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/1650#issuecomment-1061041034 | https://api.github.com/repos/simonw/datasette/issues/1650 | 1061041034 | IC_kwDOBm6k_c4_PjOK | 9599 | 2022-03-07T19:16:51Z | 2022-03-07T19:16:51Z | OWNER | Here's the problem: https://github.com/simonw/datasette/blob/020effe47bf89f35182960a9645f2383a42ebd54/datasette/utils/__init__.py#L1173-L1175 Which is called here: https://github.com/simonw/datasette/blob/1baa030eca375f839f3471237547ab403523e643/datasette/views/base.py#L469-L473 So `table%2Fwith%2Fslashes` ends up decoded as if it was using dash encoding. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1160750713 | |
https://github.com/simonw/datasette/issues/1650#issuecomment-1061038414 | https://api.github.com/repos/simonw/datasette/issues/1650 | 1061038414 | IC_kwDOBm6k_c4_PilO | 9599 | 2022-03-07T19:14:04Z | 2022-03-07T19:14:04Z | OWNER | The problem seems to be that `http://127.0.0.1:8002/fixtures/table%2Fwith%2Fslashes.csv` doesn't result in a 404 at all. If it did, it would be redirected. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1160750713 | |
https://github.com/simonw/datasette/issues/1650#issuecomment-1060864823 | https://api.github.com/repos/simonw/datasette/issues/1650 | 1060864823 | IC_kwDOBm6k_c4_O4M3 | 9599 | 2022-03-07T16:14:33Z | 2022-03-07T16:14:33Z | OWNER | Same problem here: https://fivethirtyeight.datasettes.com/fivethirtyeight/ahca-2Dpolls%2Fahca_polls should redirect but doesn't. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1160750713 | |
https://github.com/simonw/datasette/issues/1650#issuecomment-1060863311 | https://api.github.com/repos/simonw/datasette/issues/1650 | 1060863311 | IC_kwDOBm6k_c4_O31P | 9599 | 2022-03-07T16:13:17Z | 2022-03-07T16:13:17Z | OWNER | This doesn't seem to work. https://latest.datasette.io/fixtures/table%2Fwith%2Fslashes.csv should be redirecting now that this is deployed - which it is, because https://latest.datasette.io/-/versions shows 644d25d1de78a36b105cca479e7b3e4375a6eadc - but I'm not getting that redirect. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1160750713 | |
https://github.com/simonw/datasette/issues/1650#issuecomment-1060836262 | https://api.github.com/repos/simonw/datasette/issues/1650 | 1060836262 | IC_kwDOBm6k_c4_OxOm | 9599 | 2022-03-07T15:52:09Z | 2022-03-07T15:52:09Z | OWNER | This is a bit tricky. I tried this, sending a redirect only if a 404 happens: ```diff diff --git a/datasette/app.py b/datasette/app.py index 8c5480c..420664c 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -1211,6 +1211,10 @@ class DatasetteRouter: return await self.handle_404(request, send) async def handle_404(self, request, send, exception=None): + # If path contains % encoding, redirect to dash encoding + if '%' in request.scope["path"]: + await asgi_send_redirect(send, request.scope["path"].replace("%", "-")) + return # If URL has a trailing slash, redirect to URL without it path = request.scope.get( "raw_path", request.scope["path"].encode("utf8") ``` But this URL didn't work: - http://127.0.0.1:8001/fivethirtyeight/twitter-ratio%2Fsenators I was expecting that to redirect to this page: - http://127.0.0.1:8001/fivethirtyeight/twitter-2Dratio-2Fsenators But instead it took me to another 404: - http://127.0.0.1:8001/fivethirtyeight/twitter-ratio%2Fsenators This is because that URL contains both a %-escaped `/` AND a plain `-` - which was not escaped in the old system but is escaped in the new system. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1160750713 |