-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Data URLs truncated #53775
Comments
@nodejs/loaders |
I'm probably saying things you already know about, but here is it anyway: a workaround is to encode the data (e.g. Should |
thumbsup Also could base64 it.
I know it, it does this simplified parsing. I've never really been happy with it. |
I opened #53778 with a fix. |
Fixes: nodejs#53775 PR-URL: nodejs#54748 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Version
v22.4.0
Platform
Subsystem
loaders
What steps will reproduce the bug?
This snippet reproduces.
node --eval '' --import 'data:text/javascript,console.log("Whither wanders thy distempered mind?")'
This is the embedded data URL.
data:text/javascript,console.log("Whither wanders thy distempered mind?")
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
By the spec, data URLs do not have a query string or fragment.
Characters
?
#
should be allowed in the URL body.This file loads the same data URL successfully in a browser.
What do you see instead?
SyntaxError: Invalid or unexpected token
Additional information
There's a correct regex that extracts the data URL body.
node/lib/internal/modules/esm/load.js
Line 29 in b9289a6
But it's run on
URL#pathname
, which chops off query string and fragment.node/lib/internal/modules/esm/load.js
Line 44 in b9289a6
This might be a quick fix:
The text was updated successfully, but these errors were encountered: