mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 05:52:53 +00:00
LibWeb: Don't strip leading '?' in query initializing a URL
In our implementation of url-initialize, we were invoking the constructor of URLSearchParams: https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams Instead of the 'initialize' AO: https://url.spec.whatwg.org/#urlsearchparams-initialize This has the small difference of stripping any leading '?' from the query (which we are not meant to be doing!).
This commit is contained in:
parent
d7b19b3278
commit
fd4e943e12
Notes:
github-actions[bot]
2024-08-06 22:09:12 +00:00
Author: https://github.com/shannonbooth
Commit: fd4e943e12
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/987
Reviewed-by: https://github.com/tcl3 ✅
5 changed files with 34 additions and 2 deletions
|
@ -124,6 +124,14 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> URLSearchParams::create(J
|
|||
return realm.heap().allocate<URLSearchParams>(realm, realm, move(list));
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#urlsearchparams-initialize
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> URLSearchParams::create(JS::Realm& realm, StringView init)
|
||||
{
|
||||
// NOTE: We skip the other steps since we know it is a string at this point.
|
||||
// b. Set query’s list to the result of parsing init.
|
||||
return URLSearchParams::create(realm, MUST(url_decode(init)));
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
|
||||
// https://url.spec.whatwg.org/#urlsearchparams-initialize
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> URLSearchParams::construct_impl(JS::Realm& realm, Variant<Vector<Vector<String>>, OrderedHashMap<String, String>, String> const& init)
|
||||
|
@ -179,7 +187,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> URLSearchParams::construc
|
|||
auto stripped_init = init_string_view.substring_view(init_string_view.starts_with('?'));
|
||||
|
||||
// b. Set query’s list to the result of parsing init.
|
||||
return URLSearchParams::create(realm, TRY_OR_THROW_OOM(vm, url_decode(stripped_init)));
|
||||
return URLSearchParams::create(realm, stripped_init);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue