Colon in uri generate response 404
See original GitHub issueSanic can’t find the route if there’s a colon in the uri.
Code snippet
from sanic import Sanic, Request, HTTPResponse
app = Sanic('zzz')
@app.get(f'/abc/x:y')
async def main(_: Request):
return HTTPResponse()
if __name__ == '__main__':
app.run()
Expected behavior
GET http://127.0.0.1:8000/abc/x:y 200 0
Actual behavior
GET http://127.0.0.1:8000/abc/x:y 404 733
Environment
[2022-09-26 20:50:40 +0600] [13060] [INFO] Sanic v22.6.2
[2022-09-26 20:50:40 +0600] [13060] [INFO] Goin' Fast @ http://127.0.0.1:8000
[2022-09-26 20:50:40 +0600] [13060] [INFO] mode: production, single worker
[2022-09-26 20:50:40 +0600] [13060] [INFO] server: sanic, HTTP/1.1
[2022-09-26 20:50:40 +0600] [13060] [INFO] python: 3.10.5
[2022-09-26 20:50:40 +0600] [13060] [INFO] platform: Windows-10-10.0.19044-SP0
[2022-09-26 20:50:40 +0600] [13060] [INFO] packages: sanic-routing==22.3.0
[2022-09-26 20:50:40 +0600] [13060] [INFO] Starting worker [13060]
Additional context https://github.com/tiangolo/fastapi/issues/4892 https://github.com/encode/starlette/pull/1657
Issue Analytics
- State:
- Created a year ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
When a url contains colon, it makes 404 response. After I ...
When a url contains colon, it makes 404 response. After I upgrade fastapi ... Colon in uri generate response 404 sanic-org/sanic-routing#67.
Read more >Colons not being URL encoded in resource parameters
I've got around this issue by passing the URI as a query parameter instead of as part of the request URL. I did...
Read more >URL with . and : does not work - Laracasts
Basically, it works with only dots, or only colons. If the URL contains a dot and colon, a 404 is thrown. Route: Route::get('/server/{ipport}', ......
Read more >PQ77490: HAVING A SEMICOLON IN THE URL AND ... - IBM
Customer has coded multifail error404 error page, to send 404 type responses to the client. If the URI contains a semicolon then the...
Read more >Using URL encoding to handle special characters in a ...
In this article, we will walk through a scenario where exceptions are thrown if such a URI with special character is not handled...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am going to put this aside for now unless someone can make a compelling argument for why we need to handle this. It is the first time I have heard this come up and I am hesitant to add in support for this edge case when a viable alternative exists.
For anyone that needs:
Or, perhaps a try/except is warranted:
Closing as WONTFIX, given that it against specs and as @ahopkins noted a rare corner case with viable workarounds for those who need it anyway.