-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 have encoded %
in URL outside of parameter
#7554
Comments
@benmccann here is what i found:
<a href="/encoded/99%">99%</a>
decodeURI('/encoded/99%')
// Uncaught URIError: URI malformed
// at decodeURI (<anonymous>)
// at <anonymous>:1:1
decodeURI('/encoded/99%25')
// '/encoded/99%'
It seems like it is safe to use characters that are ignored by P.S. If you remove |
As a solution maybe we can check path segments on build like this: const decoded = decodeURI(segment);
if (decoded !== segment) {
throw Error('there is an unavailable encoded character') // and show original and decoded segments
} |
Thanks for catching my mistakes in the test! Sorry about that. I just pushed the fixes you mentioned I'm not sure I understand what you're suggesting might be wrong with I'm actually pretty confused at the moment because the Playwright tests are failing, but I can load the page just fine in my browser: |
@benmccann expects should be updated too: test('allows %-encoded percent character in directory names', async ({ page, clicknav }) => {
await page.goto('/encoded');
await clicknav('[href="/encoded/99%25"]');
expect(await page.textContent('h1')).toBe('dynamic');
expect(await page.textContent('h2')).toBe('/encoded/99%25: 99%');
expect(await page.textContent('h3')).toBe('/encoded/99%25: 99%');
}); |
About This is a regression with |
It is ok when kit/packages/kit/src/utils/routing.js Line 24 in 11950e0
const decoded_segment = segment.split('%25').map(decodeURIComponent).join('%25')); |
Describe the bug
#7521 will not allow you to have a URL like this:
Probably the way to fix this is to replace the parameters with placeholders, decodeURI the altered URL, match with regex, and then decodeURIComponent on the parameters
Reproduction
https://github.com/benmccann/kit/tree/encoded-percent-test
Logs
No response
System Info
`master`
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: