-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
pathToFileURL
function in url fails to handle special characters properly
#54515
Comments
I'm not sure any of the examples you show are really a problem, IIUC those characters would be problematic only in the origin; in the path it's perfectly fine. However, a problematic one would be: $ node -p 'url.pathToFileURL("\\\\server[\\foobar[", { windows: true }).href'
file:///foobar[ |
FWIW According to RFC1738, they should be encoded (see the bold):
|
When trying to access files using a file URL on Windows 11, such as The same behavior occurred on Ubuntu 22.04 when accessing a file located at This behavior was also consistent with UNC paths. However, my PR failed four tests because these tests assume that the |
Co-authored-by: EarlyRiser42 <tkfydtls464@gmail.com> PR-URL: nodejs#54545 Fixes: nodejs#54515 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Co-authored-by: EarlyRiser42 <tkfydtls464@gmail.com> PR-URL: nodejs#54545 Fixes: nodejs#54515 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Co-authored-by: EarlyRiser42 <tkfydtls464@gmail.com> PR-URL: nodejs#54545 Fixes: nodejs#54515 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Version
22.5.1
Platform
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
everytime
What is the expected behavior? Why is that the expected behavior?
I think the expected behavior is:
because
[
and]
are special characters used to specify IP addresses in URLs, and^
is generally unsafe in URLs and should also be percent-encoded.What do you see instead?
I see that
[
,]
, and^
are not encodedAdditional information
I think that setter and constructor both didn't encoded those special characters
The text was updated successfully, but these errors were encountered: