-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
% cannot be escaped in url params #1746
Comments
If I add @sveltejs/adapter-node and run preview mode, an invalid url (like
|
Can you test again with the latest version of SvelteKit? I'm wondering if this was fixed by #2078 |
in |
Thanks for the update @acoyfellow. I tracked this down to a bug in Vite and upgraded Vite, so it should be fixed in the next release of SvelteKit |
@benmccann I dont think this is actually fixed and the issue should stay open. I just tested with the latest version of sveltekit ( The original error I described ( |
well I guess we went from triple decoding to just double decoding 😕 |
So looking through the code, here's what I think is happening... We decode to match the route:
And then decode again to get the params: kit/packages/kit/src/core/dev/index.js Line 255 in 3d4172c
Which is called on the already decoded params:
I'm not entirely sure it's valid that we decode before matching the URL pattern. What if we get a request URL with |
That doesnt necessarily make sense to me either... but I will say, in the example above, the url |
thanks @benmccann! Is there a way for me to test this myself using npm to confirm the fix? Or a way to know when a particular pr has made it into a release? |
can confirm the fix works! although...for what its worth, passing in an invalid url like
The node adapter production server does not crash
|
You could file an issue with Vite. It looks like that's where it's coming from |
Describe the bug
parameterized routes do not properly parse the
%
sign in a url.If I have a url that contains a percent that needs to be escaped, I would use the function
encodeUri
. For example:What actually happens, is svelte kit reads this url as
test me
Logs
To Reproduce
create the file
src/routes/sample/[param].svelte
with the following contents:opening this url:
http://localhost:3000/sample/test%2520me
displaysparam is "test me"
Expected behavior
the page should display
param is test%20me
.Stacktraces
Information about your SvelteKit Installation:
Diagnostics
System: OS: Linux 5.12 Arch Linux CPU: (4) x64 Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz Memory: 5.48 GB / 18.96 GB Container: Yes Shell: 5.8 - /usr/bin/zsh Binaries: Node: 16.3.0 - /usr/local/bin/node Yarn: 1.22.4 - ~/.npm-packages/bin/yarn npm: 7.11.2 - ~/.npm-packages/bin/npm Browsers: Firefox: 89.0.1 npmPackages: @sveltejs/kit: next => 1.0.0-next.116 svelte: ^3.34.0 => 3.38.3Google Chrome 91.0.4472.114
Severity
I have a local web app that displays system files using a route like
src/routes/file/[...filepath].svelte
. For whatever reason, some files happen to contain %20 inside them (likely because they were encoded weirdly once upon a time. With this bug as it stands, I cannot display any files that contain percents inside them, because I have no way of telling the server that a percent is part of the filepath.Additional context
I found a possibly related issue in the polka server repo: lukeed/polka#119 (I assume polka is still the internal server)
The text was updated successfully, but these errors were encountered: