URLs with encoded characters not handled properly.
See original GitHub issueIf I have an asset with a filename test file.jpg
the corresponding url is /test%20file.jpg
, which is correct. However, getAssetFromKV
tries to access it as test%20file.jpg
which does not exist and fails.
the URL
constructor converts all spaces not already encoded to %20
automatically, so a simplistic solution would be running decodeURI
here after the url was already parsed with URL
:
https://github.com/cloudflare/kv-asset-handler/blob/d4fa91fae1806e30270dcc5f39f581ea37362a59/src/index.ts#L101
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
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 >(Please) Stop Using Unsafe Characters in URLs
All unsafe characters must always be encoded within a URL. For example, the character # must be encoded within URLs even in systems...
Read more >Which characters make a URL invalid? - Stack Overflow
Any of the reserved characters above can be legally used in a URI without encoding, either to serve their syntactic purpose or just...
Read more >How fix a URL which breaks because of Unicode content
Throw that at something which is not able to handle full Unicode characters and it will fail. Instead, that URL can contain embedded...
Read more >How should incorrectly encoded URLs be handled?
First things first, as @LazyOne said, the third-party URLs are not being properly generated, so the expectation is server to fail - as...
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
ooohhh - very interesting.
I’ve become so conditioned to respond to URL encoding issues with a recommendation to polyfill that I didn’t actually read your report.
Your diagnosis seems correct and using
decodeURI
should fix 👍Happy to accept a PR or we can add this to our list of things to address.
This will be fixed shortly in 0.0.11.