LibURL+LibWeb: Do not percent decode in password/username getters

Doing it is not part of the spec. Whenever needed, the spec will
explicitly percent decode the username and password.

This fixes some URL WPT tests.
This commit is contained in:
Shannon Booth
2024-08-04 22:02:02 +12:00
committed by Tim Ledbetter
parent a10610a1ca
commit f511c0b441
14 changed files with 62 additions and 45 deletions

View File

@@ -271,12 +271,12 @@ Optional<Header> HttpRequest::get_http_basic_authentication_header(URL::URL cons
if (!url.includes_credentials())
return {};
StringBuilder builder;
builder.append(url.username().release_value_but_fixme_should_propagate_errors());
builder.append(URL::percent_decode(url.username()));
builder.append(':');
builder.append(url.password().release_value_but_fixme_should_propagate_errors());
builder.append(URL::percent_decode(url.password()));
// FIXME: change to TRY() and make method fallible
auto token = MUST(encode_base64(MUST(builder.to_string()).bytes()));
auto token = MUST(encode_base64(builder.string_view().bytes()));
builder.clear();
builder.append("Basic "sv);
builder.append(token);