You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[vite] Internal server error: URI malformed
at decodeURI (<anonymous>)
at viteTransformMiddleware (file:///***/node_modules/vite/dist/node/chunks/dep-ByPKlqZ5.js:42708:13)
at call (file:///***/node_modules/vite/dist/node/chunks/dep-ByPKlqZ5.js:22743:7)
at next (file:///***/node_modules/vite/dist/node/chunks/dep-ByPKlqZ5.js:22687:5)
at viteHMRPingMiddleware (file:///***/node_modules/vite/dist/node/chunks/dep-ByPKlqZ5.js:44204:7)
Trying to decode the URI using decodeURI() in js results in the same error, however new URL() is able to handle it fine.
Unfortunately, I cannot change how these clients send these arguments, as it's a fully aged protocol implemented across dozens of clients.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
After some more investigation, it seems that the info_hash parameter is causing the malformed URL. The spec describes the info_hash as a "urlencoded 20-byte SHA1 hash".
As decodeURI expects all encoded parts prefixed with a % to be a valid UTF-8 character (source) and not any byte, it causes the error.
One way to fix this would to implement a custom decodeURI function to handle other bytes. Currently, decodeURI('%00') returns \u0000, maybe something similar could be implemented so other bytes are converted. Or maybe just ignore those characters and leave as is.
Describe the bug
Whenever the following path is sent to a vite app:
It will return
Trying to decode the URI using
decodeURI()
in js results in the same error, howevernew URL()
is able to handle it fine.Unfortunately, I cannot change how these clients send these arguments, as it's a fully aged protocol implemented across dozens of clients.
Reproduction
https://stackblitz.com/edit/vitejs-vite-aknq4gqx?file=index.html&terminal=dev
Steps to reproduce
System Info
Is this necessary?
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: