-
Notifications
You must be signed in to change notification settings - Fork 25
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
Incorrect handling of base URL in URLPatternInit processing #202
Comments
I don't think WebIDL conversion is applicable here, but nonetheless I agree that we need to replace null with an empty string in a few places here. |
Some of these values may be null (or in the case of port, an integer) and must be converted to strings before they can be applied to URLPatternInit. Fixes whatwg#202.
Some of these values may be null (or in the case of port, an integer) and must be converted to strings before they can be applied to URLPatternInit. Fixes whatwg#202.
@jeremyroman There's somewhat a related bug when creating a pattern parser with some of the encoding callbacks. These callbacks also rely on URL spec's basic parser and do not check for As I understand these callbacks should always return a string, as all patterns are string. |
Acknowledged on the port needing to be serialized there. The others seem fine to me, as they initialize the URL record's relevant field into a non-null state and then proceed with parsing from a state that I think will never set them back to null. Can you be more specific? |
@jeremyroman Yes, it seems fine for the other components as But should This issue is also discussed here #204 (comment) |
Some of these values may be null (or in the case of port, an integer) and must be converted to strings before they can be applied to URLPatternInit. The conversion of the port to an integer is also necessary in the encoding callbacks. Addresses #202, at least in part.
Well, it's not that they must be It is incorrect to initialize these to null; instead, we should be conditionally assigning them and leaving them absent from the map otherwise. |
It is not valid for these dictionary members to be null, since they are defined to, if present, hold a USVString value. Instead, these should be omitted from the result dictionary altogether if no string was provided to this algorithm. This addresses the concern raised in #202 (comment).
Hi @jeremyroman, hostnames seems to suffer from the same issue. The basic URL parser will parse a host as a hostname or an IP address. Addresses can be represented as an single integer or as an array of integer, so they also need to be explicitly serialized, here :
The parsed host and port in the match steps will also need to be properly serialized :
|
@jeremyroman Also: minor typo found in canonicalize a port. Argument passed as portValue and then referred as value. |
@jeremyroman @annevk I submitted a PR to fix this issue + the minor typo but it seems it's still pending. I'm new to this process, is there something else I'm missing ? |
The URL parser return port as an integer and host as either a hostname string, an integer (IPv4 address) or an array of integers (IPv6 address). For further processing by the URLPattern code these properties need to be properly converted to string. The issue was discussed here: #202
@rubycon did your PR fully resolve this issue? (i.e., shall I close it now?) |
@jeremyroman Yes, it's fully resolved! |
What is the issue with the URL Pattern Standard?
A correct implementation of the current spec fail with this kind of simple input:
The issue comes in part from the use of URL spec's internal parsers. These parsers manipulate URL records with some fields (host, port, query, fragment) that default to
null
when empty.When those empty fields are then used to fill the default url pattern (step 11-7 to 11-10 of process a URLPatternInit), the processing a base URL string assertion fail (Assert: input is not null.)
In the special case of the baseURL port, URL record use unsigned integers and not strings, so the assertion pass but the code fail further down in escape a pattern string (1. Assert: input is an ASCII string.).
As per Web IDL, implicit string conversion would yield
"null"
for those empty field (as the URL record struct is not marked[LegacyNullToEmptyString]
) which is not what we want.The spec should check if a baseURL field is not
null
before using it to fill the url pattern. As for the port it should be converted to a string but is the processing of the stringified port really necessary as we are certain its only ASCII characters and there's nothing to escape ?).The text was updated successfully, but these errors were encountered: