LibWeb: Don't propogate small OOMs from URLSearchParams

Made easier now that URL percent encode after encoding is also not
throwing any errors. This simplfies a bunch of error handling.
This commit is contained in:
Shannon Booth 2024-08-11 00:24:54 +12:00 committed by Tim Ledbetter
parent 4bb211ba88
commit df4739d7ce
Notes: github-actions[bot] 2024-08-12 22:02:35 +00:00
7 changed files with 59 additions and 77 deletions

View file

@ -59,7 +59,7 @@ JS::NonnullGCPtr<DOMURL> DOMURL::initialize_a_url(JS::Realm& realm, URL::URL con
// 2. Set urls URL to urlRecord.
// 3. Set urls query object to a new URLSearchParams object.
auto query_object = MUST(URLSearchParams::create(realm, query));
auto query_object = URLSearchParams::create(realm, query);
// 4. Initialize urls query object with query.
auto result_url = DOMURL::create(realm, url_record, move(query_object));
@ -190,8 +190,6 @@ WebIDL::ExceptionOr<String> DOMURL::to_json() const
// https://url.spec.whatwg.org/#ref-for-dom-url-href②
WebIDL::ExceptionOr<void> DOMURL::set_href(String const& href)
{
auto& vm = realm().vm();
// 1. Let parsedURL be the result of running the basic URL parser on the given value.
URL::URL parsed_url = href;
@ -210,7 +208,7 @@ WebIDL::ExceptionOr<void> DOMURL::set_href(String const& href)
// 6. If query is non-null, then set thiss query objects list to the result of parsing query.
if (query.has_value())
m_query->m_list = TRY_OR_THROW_OOM(vm, url_decode(*query));
m_query->m_list = url_decode(*query);
return {};
}
@ -411,10 +409,8 @@ WebIDL::ExceptionOr<String> DOMURL::search() const
}
// https://url.spec.whatwg.org/#ref-for-dom-url-search%E2%91%A0
WebIDL::ExceptionOr<void> DOMURL::set_search(String const& search)
void DOMURL::set_search(String const& search)
{
auto& vm = realm().vm();
// 1. Let url be thiss URL.
auto& url = m_url;
@ -430,7 +426,7 @@ WebIDL::ExceptionOr<void> DOMURL::set_search(String const& search)
strip_trailing_spaces_from_an_opaque_path(*this);
// 4. Return.
return {};
return;
}
// 3. Let input be the given value with a single leading U+003F (?) removed, if any.
@ -447,10 +443,8 @@ WebIDL::ExceptionOr<void> DOMURL::set_search(String const& search)
m_url = move(result_url);
// 6. Set thiss query objects list to the result of parsing input.
m_query->m_list = TRY_OR_THROW_OOM(vm, url_decode(input));
m_query->m_list = url_decode(input);
}
return {};
}
// https://url.spec.whatwg.org/#dom-url-searchparams