-
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
src, url: WHATWG URL C++ parser cleanup #11917
Conversation
@@ -705,10 +710,11 @@ namespace url { | |||
p++; | |||
continue; | |||
} else if (ch == ':' || (has_state_override && ch == kEOL)) { |
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 scheme
state handling seems to deviate quite a bit from the spec now?
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.
That is unfortunately true. We already deviate from the spec by storing :
as part of the scheme
, coupled by the fact that we delegate some responsibilities to the JS layer, it's hard to follow the spec word-for-word.
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.
As long as we're still API compliant and passing all the tests, such deviation is fine. It would be helpful, however, to document the deviations in code comments.
src/node_url.cc
Outdated
} else if (!has_state_override) { | ||
URL_FAILED() | ||
if (port < 0 || port > 0xffff) { | ||
// XXX: This hack is currently needed for the host setter since |
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.
Better leave a handle for it...like XXX(TimothyGu):
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.
nit: Can you just make this TODO(TimothyGu):
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.
Generally LGTM
src/node_url.cc
Outdated
} else if (!has_state_override) { | ||
URL_FAILED() | ||
if (port < 0 || port > 0xffff) { | ||
// XXX: This hack is currently needed for the host setter since |
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.
nit: Can you just make this TODO(TimothyGu):
This will need a rebase. |
I'll say this is currently blocked on #11934 as it will change TERMINATED and FAILED handling. |
@jasnell, @joyeecheung, rebased. PTAL. |
GET_AND_SET(env, base_obj, scheme, base, URL_FLAGS_HAS_SCHEME); | ||
Local<Value> scheme = GET(env, base_obj, "scheme"); | ||
base->scheme = Utf8Value(env->isolate(), scheme).out(); | ||
|
||
GET_AND_SET(env, base_obj, username, base, URL_FLAGS_HAS_USERNAME); |
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.
Eventually it would likely be better just to inline this and get rid of the macro
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.
Generally LGTM with a couple of suggestions
@@ -444,7 +444,6 @@ static inline void PercentDecode(const char* input, | |||
XX(URL_FLAGS_INVALID_PARSE_STATE, 0x04) \ | |||
XX(URL_FLAGS_TERMINATED, 0x08) \ | |||
XX(URL_FLAGS_SPECIAL, 0x10) \ |
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.
Likely worthwhile to decrement each of the remaining flags accordingly so that there's not a gap.
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.
Fixed. I was planning on some more refactoring, but that didn't happen.
Is this ready to go? |
@jasnell, go ahead with landing this if you'd like to. I've been busy the last couple of days. |
Rebased and one last CI: https://ci.nodejs.org/job/node-test-pull-request/7099/ |
Do not call any completion callback with TERMINATED.
Landed in 4ddd23f. |
- Clarify port state - Remove scheme flag - Clarify URL_FLAG_TERMINATED PR-URL: #11917 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
cc @TimothyGu |
Some general housekeeping for the WHATWG URL implementation.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src, url