url: return valid file: urls fom url.format()#7234
url: return valid file: urls fom url.format()#7234Trott wants to merge 3 commits intonodejs:masterfrom
Conversation
lib/url.js
Outdated
There was a problem hiding this comment.
minor nit: last time i checked template strings had noticeable overhead, may need to check again on master now.
There was a problem hiding this comment.
Changed to string concatenation.
`file:` URLs that do not start with `file://` are invalid. Browsers convert `file:/etc/passwd` to `file:///etc/passwd`. This is also what the docs indicate we are doing, but we're not. Fixes: nodejs#3361
|
/cc @silverwind @claudiorodriguez (who had substantial comments on the issue this tries to address) |
|
LGTM if CI passes. |
|
I guess since it's semver-major and our docs say that semver-major changes need to be reviewed in some fashion by CTC: @nodejs/ctc |
|
Couple of unrelated-seeming issues on that first CI run. Here's a second one: https://ci.nodejs.org/job/node-test-commit/3707/ |
|
LGTM |
|
@jasnell This would seem to be orthogonal to nodejs/node-eps#28 but uh, just in case, care to review? |
| pathname = '/' + pathname; | ||
| host = '//' + host; | ||
| } else if (protocol.length >= 4 && | ||
| protocol.charCodeAt(0) === 102/*f*/ && |
There was a problem hiding this comment.
@indutny I used decimal because:
- It's decimal in most of the existing
charCodeAt()calls, including ~10 lines later in lines 621 and 622, as well as theswitchstatement ~30 lines earlier starting on line 581. - The sample code (provided by @mscdex) used decimal and I did a lazy copy/paste.
I don't feel strongly about it, though, and I'm happy to change it to hex format if that's the difference between a quick LGTM and a not-sure-about-this.
|
Trying to get more eyes on this... @nodejs/collaborators |
|
Adding |
|
For anyone here wondering what whatwg-url spec does, ref: https://url.spec.whatwg.org/#url-serializing. It always starts |
|
no objections from ctc |
`file:` URLs that do not start with `file://` are invalid. Browsers convert `file:/etc/passwd` to `file:///etc/passwd`. This is also what the docs indicate we are doing, but we're not. PR-URL: nodejs#7234 Fixes: nodejs#3361 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Brian White <mscdex@mscdex.net>
|
Landed in 336b027 |
Checklist
make -j4 test(UNIX) orvcbuild test nosign(Windows) passesAffected core subsystem(s)
url
Description of change
file:URLs that do not start withfile://are invalid. Browsers convertfile:/etc/passwdtofile:///etc/passwd. This is also what the docs indicate we are doing, but we're not.Labeling
semver-majorbecause tests have to be updated for it.Fixes: #3361