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

Default to WHATWG URL parser in http.request (and friends) #19468

Closed
TimothyGu opened this issue Mar 20, 2018 · 3 comments
Closed

Default to WHATWG URL parser in http.request (and friends) #19468

TimothyGu opened this issue Mar 20, 2018 · 3 comments
Labels
http Issues or PRs related to the http subsystem. url Issues and PRs related to the legacy built-in url module. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Comments

@TimothyGu
Copy link
Member

  • Version: master
  • Platform: all
  • Subsystem: http

Currently, http.request('http://brave.com%60x.code-fu.org/') requests http://brave.com/%60x.code-fu.org/ rather than http://brave.com`x.code-fu.org/. This behavior deviates from the behavior standardized in WHATWG URL Standard and used in browsers, and have caused dangerous security implications for downstream embedders (see talk by @diracdeltas).

This is due to the http.request function using the legacy url.parse function rather than the new WHATWG-compliant URL parser. We should switch the URL parser used for string-typed argument to the standard-complaint parser.

This switch will surely have compatibility implications, but I doubt it will cause major breakage since most request-style libraries pass in an object instead of a string as the first argument anyway.

/cc @annevk @BrendanEich (See original tweet.)

@TimothyGu TimothyGu added http Issues or PRs related to the http subsystem. url Issues and PRs related to the legacy built-in url module. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Mar 20, 2018
@jasnell
Copy link
Member

jasnell commented Mar 20, 2018

+1 on this. This was my intent originally when introducing the WHATWG URL parser but I wanted to give the new implementation time to be stable before introducing the change.

There are some hidden gotchas in here. The net code is currently written to assume url.parse() is used and is currently set up at multiple levels to consume the parsed object it provides as opposed to the actual URL class produced by the new parser.

@TimothyGu
Copy link
Member Author

@jasnell I was thinking we could just convert the created URL object to the internally used Url format right after parsing, using the conversion function already available to us. That wouldn’t cause as much churn.

@Hackzzila
Copy link
Contributor

I have implemented this in #20270. I think it would be good improvement to v11. By that time the WHATWG URL parser will have had about 18 months to stabilize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem. url Issues and PRs related to the legacy built-in url module. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

No branches or pull requests

3 participants