-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix invalid urlpattern test(s) #49782
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1145,6 +1145,14 @@ | |
| { | ||
| "pattern": [{ "protocol": "http", "port": "80 " }], | ||
| "inputs": [{ "protocol": "http", "port": "80" }], | ||
| "exactly_empty_components": ["port"], | ||
| "expected_match": { | ||
| "protocol": { "input": "http", "groups": {} } | ||
| } | ||
| }, | ||
| { | ||
| "pattern": [{ "protocol": "http", "port": "100000" }], | ||
| "inputs": [{ "protocol": "http", "port": "100000" }], | ||
| "expected_obj": "error" | ||
| }, | ||
| { | ||
|
|
@@ -2367,15 +2375,24 @@ | |
| }, | ||
| { | ||
| "pattern": [{ "hostname": "bad#hostname" }], | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you clarify why only btw I noticed "bad\:hostname" updates hostname in URL.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Host parser (specifically domain to ASCII with domain and false) strip all trailing values whenever it sees # https://url.spec.whatwg.org/#concept-host-parser
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The host parser does not do that. Do you mean the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, I meant the host setter, which calls the host parser.
@sisidovski Sorry I missed this comment. URL spec hostname state step 3 (ref: https://url.spec.whatwg.org/#hostname-state) says that... if c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#) ... then decrease pointer by 1, and then: ... Let host be the result of host parsing buffer with url is not special. So, if you see these characters, we take the existing non-empty buffer and parse it as a valid hostname. |
||
| "expected_obj": "error" | ||
| "exactly_empty_components": ["port"], | ||
| "expected_match": { | ||
| "hostname": { "input": "bad", "groups": {} } | ||
| } | ||
| }, | ||
| { | ||
| "pattern": [{ "hostname": "bad%hostname" }], | ||
| "expected_obj": "error" | ||
| "exactly_empty_components": ["port"], | ||
anonrig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "expected_match": { | ||
| "hostname": { "input": "bad%hostname", "groups": {} } | ||
| } | ||
| }, | ||
| { | ||
| "pattern": [{ "hostname": "bad/hostname" }], | ||
| "expected_obj": "error" | ||
| "exactly_empty_components": ["port"], | ||
| "expected_match": { | ||
| "hostname": { "input": "bad", "groups": {} } | ||
| } | ||
| }, | ||
| { | ||
| "pattern": [{ "hostname": "bad\\:hostname" }], | ||
|
|
@@ -2419,15 +2436,24 @@ | |
| }, | ||
| { | ||
| "pattern": [{ "hostname": "bad\nhostname" }], | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is defined in URL spec. All ascii tab or newline are removed from the input before any parsing is done.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, |
||
| "expected_obj": "error" | ||
| "exactly_empty_components": ["port"], | ||
| "expected_match": { | ||
| "hostname": { "input": "badhostname", "groups": {} } | ||
| } | ||
| }, | ||
| { | ||
| "pattern": [{ "hostname": "bad\rhostname" }], | ||
| "expected_obj": "error" | ||
| "exactly_empty_components": ["port"], | ||
| "expected_match": { | ||
| "hostname": { "input": "badhostname", "groups": {} } | ||
| } | ||
| }, | ||
| { | ||
| "pattern": [{ "hostname": "bad\thostname" }], | ||
| "expected_obj": "error" | ||
| "exactly_empty_components": ["port"], | ||
| "expected_match": { | ||
| "hostname": { "input": "badhostname", "groups": {} } | ||
| } | ||
| }, | ||
| { | ||
| "pattern": [{}], | ||
|
|
||
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 don't quite follow what the intention of this test case is. Could you help me to understand?
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.
Definitely. It tests the maximum valid port number. If it is greater than 65k, it should throw (according to url spec)
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.
Thanks. This is for the step 2.1.2 in the port state in the basic-url-parser. That makes sense.