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

fix invalid urlpattern test(s) #49782

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Dec 19, 2024

Fixes whatwg/urlpattern#239

Port calls canonicalizePort which just calls url parser setter, which removes the leading trailing c0 whitespace characters from the input.

cc @annevk @lucacasonato @sisidovski

@wpt-pr-bot
Copy link
Collaborator

There are no reviewers for this pull request. Please reach out on the chat room to get help with this. Thank you!

@annevk
Copy link
Member

annevk commented Dec 19, 2024

cc @sisidovski

@annevk
Copy link
Member

annevk commented Dec 19, 2024

Aside: are there no tests where port is assigned to something that is clearly not a port?

@anonrig anonrig force-pushed the anonrig/fix-wpt-for-urlpattern branch 3 times, most recently from d66cd3c to 1e055be Compare December 19, 2024 15:50
@anonrig
Copy link
Member Author

anonrig commented Dec 19, 2024

Aside: are there no tests where port is assigned to something that is clearly not a port?

@annevk I'm not sure. By the way, port is not the only wrong test here. As I progress with Ada's implementation, it seems hostname tests are also wrong.

@anonrig anonrig force-pushed the anonrig/fix-wpt-for-urlpattern branch from 1e055be to 68ffecf Compare December 19, 2024 15:53
@anonrig anonrig force-pushed the anonrig/fix-wpt-for-urlpattern branch from 68ffecf to 153c3e9 Compare December 19, 2024 15:54
@anonrig
Copy link
Member Author

anonrig commented Dec 19, 2024

@annevk I've added a new commit that includes a test for a failing port field.

@anonrig anonrig changed the title fix invalid urlpattern test fix invalid urlpattern test(s) Dec 19, 2024
@anonrig anonrig mentioned this pull request Dec 19, 2024
7 tasks
@lucacasonato
Copy link
Member

See whatwg/urlpattern#239 (comment) - I am not entirely sure your analysis for port is correct.

@annevk
Copy link
Member

annevk commented Feb 20, 2025

It seems that concern was resolved.

@sisidovski and @jeremyroman can you please review this?

},
{
"pattern": [{ "protocol": "http", "port": "100000" }],
"inputs": [{ "protocol": "http", "port": "100000" }],
Copy link
Contributor

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?

Copy link
Member Author

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)

Copy link
Contributor

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.

},
{
"pattern": [{ "protocol": "http", "port": "100000" }],
"inputs": [{ "protocol": "http", "port": "100000" }],
Copy link
Contributor

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.

@@ -2419,15 +2436,24 @@
},
{
"pattern": [{ "hostname": "bad\nhostname" }],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are \n, \r, and \t just stripped?

@@ -2367,15 +2375,24 @@
},
{
"pattern": [{ "hostname": "bad#hostname" }],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify why only #%/ don't throw errors and other hostname patterns like "bad\:hostname" or "bad>hostname" continue throw errors?

btw I noticed "bad\:hostname" updates hostname in URL.

u = new URL('http:/dummy.site')
u.hostname = "bad\\:hostname"
u.hostname  // bad

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The host parser does not do that. Do you mean the host setter or some such?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spec and WPT inconsistencies
5 participants