-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Unsafe parsing of URLs #8747
Comments
Yes, there are a number of known issues with the algorithm in |
In short, if you omit |
As a workaround I am going to use https://github.com/jsdom/whatwg-url |
It's simpler than that. Without a |
In the browser you'll get an error with those URLs if you don't provide a base URL:
|
@bnoordhuis: no. If you do: url.parse('user:pass@hostname.com') = {
protocol: 'user:',
slashes: null,
auth: 'pass',
host: 'hostname.com',
port: null,
hostname: 'hostname.com',
hash: null,
search: null,
query: null,
pathname: null,
path: null,
href: 'user:pass@hostname.com'
} It is parsed differently, and there's still an absence of |
|
|
You misunderstand @lpinca. |
@arboreal84 If you're willing to create a PR to update this info in the documentation so that other people don't run into the same issue then that'd be great! |
@arboreal84 The current That said, note that most of your examples are in fact behaving exactly as they should and are consistent with WHATWG URL or are not valid URLs at all and should fail in WHATWG URL. For example, if > new URL('user:pass@hostname.com')
URL {
hash: ""
host: ""
hostname: ""
href: "user:pass@hostname.com"
origin: "user://"
password: ""
pathname: "pass@hostname.com"
port: ""
protocol: "user:"
search: ""
searchParams: URLSearchParams
username: ""
__proto__: URL
} You should consult URL specification probably. |
More specifically, per spec:
|
Yep, the protocol is pretty much mandatory for parsing URLs with either the |
As a follow up to this issue: now the |
url.parse
Some cases in which I would expect
url.parse
to behave differently:IPv4 address
IPv4 address with port
IPv6 address
IPv6 address with port
Hostname
Hostname with port
The text was updated successfully, but these errors were encountered: