-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
LibWeb/URL: Add strip_trailing_spaces_from_an_opaque_path()
#21021
Conversation
82b1c27
to
ff2099b
Compare
Interestingly, seems like there is a change being proposed that is removing this section of the spec: whatwg/url#785 (only up for discussion right now) |
Nice find! From reading it (and my basic knowledge of character encoding that I should to work on), I believe some of the possible approaches they give would not have too much of an impact on my implementation. |
Tests/LibWeb/Text/expected/URL/strip_trailing_spaces_from_opaque_path.txt
Outdated
Show resolved
Hide resolved
Recent snapshot implements Even weirder, when I tried to do it myself by returning a |
The most recent change removes I also had to modify 2 let url = new URL("http://example.com/_ünicöde_téxt_©");
undefined
url.pathname
'/_%C3%BCnic%C3%B6de_t%C3%A9xt_%C2%A9'
let url = new URL("http://example.com/a%23test");
undefined
url.pathname
'/a%23test' their expected output follows inline with the changes I made to these test cases. I also made changes to the |
ff97b57
to
0cc239b
Compare
My recent change fixes a comment typo |
I think we need to preserve the behaviour of the existing AK tests here. Existing code in serenity outside of Web specs expect that the path is percent decoded. I removed this flag in: db5ad0c since nothing was actually setting that flag, and also fixed some places that were percent decoding when we shouldn't have. But it appears I shouldn't have removed that flag for "serialized_path" (or we need a different API which is a bit more clear?) - we need to be setting it here to follow web specs but not for serenity code outside of LibWeb which expected a percent-decoded path. |
This commit also reverts db5ad0c since code outside of the web spec expects serialized paths to be percent decoded. Also, there are issues trying to implement the concept "opaque path". For now, we still use the old cannot_be_a_base_url(), but its usage needs to be removed in favor of a has_opaque_path() as the spec has changed since then.
Hello! One or more of the commit messages in this PR do not match the SerenityOS code submission policy, please check the |
Since the spec expects us to use AK::URL::serialize_path() without doing any percent decoding.
I should note that I changed the signature of |
Also remove 2 FIXMEs by including this function.
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.
Looks reasonable to me
builder.append('/'); | ||
builder.append(percent_decode(path)); | ||
|
||
// Let output be the empty string. |
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.
Hm. Kind of weird that the spec has a bulleted list for this instead of a numbered list. Might be worth a spec issue in https://github.com/whatwg/url if you're feeling speccy :)
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.
Yea I wasn't too sure if this was intentional too. I'll file an issue there 👍
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.
Opened an issue at whatwg/url#786
Adds https://url.spec.whatwg.org/#potentially-strip-trailing-spaces-from-an-opaque-path.
Tested the code paths in
set_search()
andset_hash()
and they appear fine, though I think the design may be questionable, specifically with exposing more methods and delegating the work in those methods toAK::URL
.