1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00

AK+Everywhere: Add ApplyPercentDecoding option to URL getters

The defaults selected for this are based on the behaviour of URL
when it applied percent decoding during parsing. This does mean now
in some cases the getters will allocate, but percent_decode() checks
if there's anything to decode first, so in many cases still won't.
This commit is contained in:
MacDue 2023-04-13 23:06:58 +01:00 committed by Andreas Kling
parent b9e03071cc
commit 5acd40c525
3 changed files with 43 additions and 18 deletions

View file

@ -147,7 +147,7 @@ WebIDL::ExceptionOr<void> URL::set_href(String const& href)
m_query->m_list.clear();
// 5. Let query be thiss URLs query.
auto& query = m_url.query();
auto query = m_url.query();
// 6. If query is non-null, then set thiss query objects list to the result of parsing query.
if (!query.is_null())
@ -203,7 +203,7 @@ void URL::set_username(String const& username)
return;
// 2. Set the username given thiss URL and the given value.
m_url.set_username(AK::URL::percent_encode(username, AK::URL::PercentEncodeSet::Userinfo));
m_url.set_username(username.to_deprecated_string(), AK::URL::ApplyPercentEncoding::Yes);
}
// https://url.spec.whatwg.org/#dom-url-password
@ -223,7 +223,7 @@ void URL::set_password(String const& password)
return;
// 2. Set the password given thiss URL and the given value.
m_url.set_password(AK::URL::percent_encode(password, AK::URL::PercentEncodeSet::Userinfo));
m_url.set_password(password.to_deprecated_string(), AK::URL::ApplyPercentEncoding::Yes);
}
// https://url.spec.whatwg.org/#dom-url-host