Skip to content
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

decodeURI happening twice on a request causing server to crash #13298

Open
1 task done
patheticGeek opened this issue Feb 23, 2025 · 0 comments · May be fixed by #13303
Open
1 task done

decodeURI happening twice on a request causing server to crash #13298

patheticGeek opened this issue Feb 23, 2025 · 0 comments · May be fixed by #13303
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@patheticGeek
Copy link

patheticGeek commented Feb 23, 2025

Astro Info

Astro                    v5.3.0
Node                     v18.20.3
System                   Linux (x64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/svelte

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When a request comes, the pathname is decoded and set in vite-plugin-astro-server/request.ts
but then in routing/match.ts -> matchAllRoutes we try to decode the uri again for some reason

this double decoding will break on routes such as:
original uri - /d/_'%22()&%25%3Czzz%3E%3CScRiPt%20%3EjEUh(9725)%3C%2fScRiPt%3E_4pGyF4moGuWlju5fyPal9rk6Zu7C8E77dNJetF_tSY0
decodeURI result - /d/_'"()&%<zzz><ScRiPt >jEUh(9725)<%2fScRiPt>_4pGyF4moGuWlju5fyPal9rk6Zu7C8E77dNJetF_tSY0

which if you try to decode again throws an error

Log:

URIError: URI malformed
    at decodeURI (<anonymous>)
    at file:///home/work/company/node/services/next/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]__lgghma3k6xpffmxk56i5opga3e/node_modules/astro/dist/core/routing/match.js:12:31
    at Array.filter (<anonymous>)
    at matchAllRoutes (file:///home/work/company/node/services/next/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]__lgghma3k6xpffmxk56i5opga3e/node_modules/astro/dist/core/routing/match.js:10:26)
    at matchRoute (file:///home/work/company/node/services/next/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]__lgghma3k6xpffmxk56i5opga3e/node_modules/astro/dist/vite-plugin-astro-server/route.js:33:19)
    at run (file:///home/work/company/node/services/next/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]__lgghma3k6xpffmxk56i5opga3e/node_modules/astro/dist/vite-plugin-astro-server/request.js:40:34)
    at runWithErrorHandling (file:///home/work/company/node/services/next/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]__lgghma3k6xpffmxk56i5opga3e/node_modules/astro/dist/vite-plugin-astro-server/controller.js:64:11)
    at handleRequest (file:///home/work/company/node/services/next/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]__lgghma3k6xpffmxk56i5opga3e/node_modules/astro/dist/vite-plugin-astro-server/request.js:35:9)

What's the expected result?

The decode uri happens once and no error is emitted

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-gwdsqj

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Feb 23, 2025
@ematipico ematipico added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Feb 24, 2025
@ematipico ematipico self-assigned this Feb 24, 2025
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Feb 24, 2025
@ematipico ematipico linked a pull request Feb 24, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants