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

src, url: WHATWG URL C++ parser cleanup #11917

Closed
wants to merge 3 commits into from

Conversation

TimothyGu
Copy link
Member

Some general housekeeping for the WHATWG URL implementation.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

src, url

@TimothyGu TimothyGu added c++ Issues and PRs that require attention from people who are familiar with C++. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Mar 18, 2017
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. dont-land-on-v4.x whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Mar 18, 2017
@TimothyGu
Copy link
Member Author

@@ -705,10 +710,11 @@ namespace url {
p++;
continue;
} else if (ch == ':' || (has_state_override && ch == kEOL)) {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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
Copy link
Member

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):

Copy link
Member

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):

@jasnell jasnell self-assigned this Mar 21, 2017
Copy link
Member

@jasnell jasnell left a 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
Copy link
Member

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):

@jasnell
Copy link
Member

jasnell commented Mar 22, 2017

This will need a rebase.

@TimothyGu
Copy link
Member Author

I'll say this is currently blocked on #11934 as it will change TERMINATED and FAILED handling.

@TimothyGu TimothyGu added the blocked PRs that are blocked by other issues or PRs. label Mar 22, 2017
@TimothyGu TimothyGu removed the blocked PRs that are blocked by other issues or PRs. label Mar 23, 2017
@TimothyGu
Copy link
Member Author

@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);
Copy link
Member

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

Copy link
Member

@jasnell jasnell left a 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) \
Copy link
Member

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.

Copy link
Member Author

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.

@jasnell
Copy link
Member

jasnell commented Mar 27, 2017

Is this ready to go?

@jasnell jasnell added this to the 8.0.0 milestone Mar 27, 2017
@TimothyGu
Copy link
Member Author

@jasnell, go ahead with landing this if you'd like to. I've been busy the last couple of days.

@jasnell
Copy link
Member

jasnell commented Mar 27, 2017

@TimothyGu
Copy link
Member Author

Rebased and one last CI: https://ci.nodejs.org/job/node-test-pull-request/7099/

Do not call any completion callback with TERMINATED.
@TimothyGu
Copy link
Member Author

Landed in 4ddd23f.

@TimothyGu TimothyGu closed this Mar 30, 2017
@TimothyGu TimothyGu deleted the url-cleanup branch March 30, 2017 05:20
TimothyGu added a commit that referenced this pull request Mar 30, 2017
- 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>
@jasnell jasnell mentioned this pull request Apr 4, 2017
@italoacasas
Copy link
Contributor

cc @TimothyGu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants