-
Notifications
You must be signed in to change notification settings - Fork 330
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
Mutating path of URL without authority (idempotency, empty path segments) #984
Comments
x11x
changed the title
Mutating path of URL without authority (idempotence, empty path segments)
Mutating path of URL without authority (idempotency, empty path segments)
Oct 21, 2024
I think this will be fixed by #943 |
This assert: // **FAILS**
// EXPECTED: "web+demo:/.//not-a-host"
// ACTUAL: "web+demo:/not-a-host"
assert_eq!(url.as_str(), "web+demo:/.//not-a-host"); Still fails:
|
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have found a couple more cases related to #601 (whatwg/url#505; number 3. under 4.5. URL Serializing), affecting the ability to serialize idempotently when the path looks like an authority. (i.e. the
web+demo:/.//not-a-host
->web+demo://not-a-host
problem demonstrated in the spec).It occurs when mutating the path of a non-"cannot-be-a-base" URL without an authority.
(note that
"web+demo:/"
is not "cannot-be-a-base" because path is"/"
).(sorry for multiple failing assertions in the same test case, i just thought it was clearer to communicate that way)
Have I misread the spec?
I am following the rules in URL Serializing section, but is this different to URL Writing? (should URL Writing be followed for mutating path)? Possibly if you follow URL Writing it would disallow setting this type of path? (I'm not super clear on this).
But it specifies that URL-path-segment strings may be empty strings, so its a little ambiguous whether "/" followed by empty path segment followed by "/" is allowed. But the fact that this kind of path is explicitly mentioned in URL Serializing makes it seem like this should be allowed.
I also looked at the specification of the URL API pathname setter and it says to parse it using the "basic URL parser" starting in the "path start state", which I think should respect empty path segments and makes it seem like "//not-a-host" should be a valid path to set, and should cause the resultant URL to have "//not-a-host" as its path.
What do other implementations do?
I have not tested widely, just JavaScript URL class in a few runtimes i have handy
Pushing empty path segment
As well as the not serializing correctly issue, there is possibly another issue with
url::PathSegmentsMut::extend
/url::PathSegmentsMut::push
not being able to append an empty segment onto the path "/" (unless I have misunderstood how it is supposed to work or misunderstood the spec). That maybe should be a separate issue.Originally posted by @x11x in #601 (comment)
The text was updated successfully, but these errors were encountered: