-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
url: handle windows drive letter in the file state #12808
Conversation
Oops! It looks like you copied other tests ... which was already in your tests file. Correct ones are commented |
Opps sorry! I re-copied them and got an error in {
"input": "C|",
"base": "file://host/dir/file",
"href": "file:///C:",
"protocol": "file:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "/C:",
"search": "",
"hash": ""
}, I will work on it tonight. Thanks for pointing it :) @rmisev |
CI: https://ci.nodejs.org/job/node-test-commit/9600/ |
src/node_url.cc
Outdated
if ((!IsWindowsDriveLetter(ch, p[1]) || | ||
end - p == 1 || | ||
(p[2] != '/' && | ||
if ((end - p == 0 || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remaining means after ch, so p[0] must not be counted here. Correct to end - (p+1) == 0
or just end - p == 1
There is an example, which explains the term remaining: https://url.spec.whatwg.org/#remaining
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it works! Thanks for your comment :)
src/node_url.cc
Outdated
(p[2] != '/' && | ||
if ((end - p == 0 || | ||
!IsWindowsDriveLetter(ch, p[1]) || | ||
(end - p >= 2 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as above: end - (p+1) >= 2
or just end - p >= 3
The last CI doesn’t look so good… :/ |
@addaleax Yeah sorry, I was WIP at the time without the |
Okay, new CI then: https://ci.nodejs.org/job/node-test-commit/9608/ :) |
src/node_url.cc
Outdated
if ((!IsWindowsDriveLetter(ch, p[1]) || | ||
end - p == 1 || | ||
(p[2] != '/' && | ||
if ((end - p == 1 || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on the spec writer's intention (whatwg/url#308) changing end - p == 1
to end - p <= 1
might be more robust to cover ch == kEOL
as well, but in any case it shouldn't matter since the case when ch == kEOL
is covered in another case
already. Also, nice catch on noticing the end - p == 1
in the original code should actually be end - p == 2
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like they agree with me.
We can also calculate per iteration an actual remaining variable, like we are already doing for some other functions in the file. This should eliminate any confusion around this variable. The most correct implementation would be something like const size_t remaining = end == pointer ? 0 : (end - pointer - 1);
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woo that'd be nice! I'm going to update it 😺
it's gonna be like
const size_t remaining = end == pointer ? 0 : (end - pointer - 1);
......
if ((remaining == 0 ||
!IsWindowsDriveLetter(ch, p[1]) ||
(remaining >= 2 &&
p[2] != '/' &&
p[2] != '\\' &&
p[2] != '?' &&
p[2] != '#'))) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced end - pointer
with remaining
I added.
`C|` should not satisfy the condition to not copy the base's path. It also synchronises WPT url test data to verify the update in upstream. Refs: whatwg/url#305 Refs: web-platform-tests/wpt#5754
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Landed in 943dd5f. |
`C|` should not satisfy the condition to not copy the base's path. It also synchronises WPT url test data to verify the update in upstream. PR-URL: #12808 Refs: whatwg/url#305 Refs: web-platform-tests/wpt#5754 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
`C|` should not satisfy the condition to not copy the base's path. It also synchronises WPT url test data to verify the update in upstream. PR-URL: nodejs#12808 Refs: whatwg/url#305 Refs: web-platform-tests/wpt#5754 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
`C|` should not satisfy the condition to not copy the base's path. It also synchronises WPT url test data to verify the update in upstream. PR-URL: nodejs#12808 Refs: whatwg/url#305 Refs: web-platform-tests/wpt#5754 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
`C|` should not satisfy the condition to not copy the base's path. It also synchronises WPT url test data to verify the update in upstream. PR-URL: #12808 Refs: whatwg/url#305 Refs: web-platform-tests/wpt#5754 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
In the
whatwg-url
,C|
should not satisfy the condition to not copy the base's path. This patch also synchronises WPT url test data to verify the update in upstream.Refs: whatwg/url#305
Refs: web-platform-tests/wpt#5754
Checklist
make -j4 test
Affected core subsystem(s)
url