diff --git a/Userland/Libraries/LibURL/Parser.cpp b/Userland/Libraries/LibURL/Parser.cpp index af1c710acb1..d2ff2c206fe 100644 --- a/Userland/Libraries/LibURL/Parser.cpp +++ b/Userland/Libraries/LibURL/Parser.cpp @@ -75,7 +75,7 @@ static Optional parse_opaque_host(StringView input) // currently report validation errors, they are only useful for debugging efforts in the URL parsing code. // 4. Return the result of running UTF-8 percent-encode on input using the C0 control percent-encode set. - return String::from_byte_string(percent_encode(input, PercentEncodeSet::C0Control)).release_value_but_fixme_should_propagate_errors(); + return percent_encode(input, PercentEncodeSet::C0Control); } struct ParsedIPv4Number { diff --git a/Userland/Libraries/LibURL/URL.cpp b/Userland/Libraries/LibURL/URL.cpp index 31eff8dfb2d..5a9b4d248aa 100644 --- a/Userland/Libraries/LibURL/URL.cpp +++ b/Userland/Libraries/LibURL/URL.cpp @@ -59,21 +59,19 @@ void URL::set_scheme(String scheme) } // https://url.spec.whatwg.org/#set-the-username -ErrorOr URL::set_username(StringView username) +void URL::set_username(StringView username) { // To set the username given a url and username, set url’s username to the result of running UTF-8 percent-encode on username using the userinfo percent-encode set. - m_data->username = TRY(String::from_byte_string(percent_encode(username, PercentEncodeSet::Userinfo))); + m_data->username = percent_encode(username, PercentEncodeSet::Userinfo); m_data->valid = compute_validity(); - return {}; } // https://url.spec.whatwg.org/#set-the-password -ErrorOr URL::set_password(StringView password) +void URL::set_password(StringView password) { // To set the password given a url and password, set url’s password to the result of running UTF-8 percent-encode on password using the userinfo percent-encode set. - m_data->password = TRY(String::from_byte_string(percent_encode(password, PercentEncodeSet::Userinfo))); + m_data->password = percent_encode(password, PercentEncodeSet::Userinfo); m_data->valid = compute_validity(); - return {}; } void URL::set_host(Host host) @@ -103,13 +101,13 @@ void URL::set_paths(Vector const& paths) m_data->paths.clear_with_capacity(); m_data->paths.ensure_capacity(paths.size()); for (auto const& segment : paths) - m_data->paths.unchecked_append(String::from_byte_string(percent_encode(segment, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors()); + m_data->paths.unchecked_append(percent_encode(segment, PercentEncodeSet::Path)); m_data->valid = compute_validity(); } void URL::append_path(StringView path) { - m_data->paths.append(String::from_byte_string(percent_encode(path, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors()); + m_data->paths.append(percent_encode(path, PercentEncodeSet::Path)); } // https://url.spec.whatwg.org/#cannot-have-a-username-password-port @@ -444,7 +442,7 @@ void append_percent_encoded_if_necessary(StringBuilder& builder, u32 code_point, builder.append_code_point(code_point); } -ByteString percent_encode(StringView input, PercentEncodeSet set, SpaceAsPlus space_as_plus) +String percent_encode(StringView input, PercentEncodeSet set, SpaceAsPlus space_as_plus) { StringBuilder builder; for (auto code_point : Utf8View(input)) { @@ -453,7 +451,7 @@ ByteString percent_encode(StringView input, PercentEncodeSet set, SpaceAsPlus sp else append_percent_encoded_if_necessary(builder, code_point, set); } - return builder.to_byte_string(); + return MUST(builder.to_string()); } ByteString percent_decode(StringView input) diff --git a/Userland/Libraries/LibURL/URL.h b/Userland/Libraries/LibURL/URL.h index 31b17e0d202..2d31f0ef962 100644 --- a/Userland/Libraries/LibURL/URL.h +++ b/Userland/Libraries/LibURL/URL.h @@ -70,7 +70,7 @@ enum class SpaceAsPlus { No, Yes, }; -ByteString percent_encode(StringView input, PercentEncodeSet set = PercentEncodeSet::Userinfo, SpaceAsPlus = SpaceAsPlus::No); +String percent_encode(StringView input, PercentEncodeSet set = PercentEncodeSet::Userinfo, SpaceAsPlus = SpaceAsPlus::No); ByteString percent_decode(StringView input); template @@ -140,8 +140,8 @@ public: bool is_special() const { return is_special_scheme(m_data->scheme); } void set_scheme(String); - ErrorOr set_username(StringView); - ErrorOr set_password(StringView); + void set_username(StringView); + void set_password(StringView); void set_host(Host); void set_port(Optional); void set_paths(Vector const&); diff --git a/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp b/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp index fb86cb0508a..f931c3b47cd 100644 --- a/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp +++ b/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp @@ -260,7 +260,7 @@ void DOMURL::set_username(String const& username) return; // 2. Set the username given this’s URL and the given value. - MUST(m_url.set_username(username)); + m_url.set_username(username); } // https://url.spec.whatwg.org/#dom-url-password @@ -278,7 +278,7 @@ void DOMURL::set_password(String const& password) return; // 2. Set the password given this’s URL and the given value. - MUST(m_url.set_password(password)); + m_url.set_password(password); } // https://url.spec.whatwg.org/#dom-url-host diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index 1ac84ea3d3b..9fe366a2588 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -2024,10 +2024,10 @@ WebIDL::ExceptionOr> http_network_or_cache_fet auto password = ByteString::empty(); // 3. Set the username given request’s current URL and username. - MUST(request->current_url().set_username(username)); + request->current_url().set_username(username); // 4. Set the password given request’s current URL and password. - MUST(request->current_url().set_password(password)); + request->current_url().set_password(password); } // 4. Set response to the result of running HTTP-network-or-cache fetch given fetchParams and true. diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index e499a543176..666929a3131 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -845,8 +845,7 @@ ErrorOr HTMLFormElement::mail_as_body(URL::URL parsed_action, Vectorset_username(username)); + url->set_username(username); // 5. Update href. update_href(); @@ -151,7 +151,7 @@ void HTMLHyperlinkElementUtils::set_password(StringView password) return; // 4. Set the password, given url and the given value. - MUST(url->set_password(password)); + url->set_password(password); // 5. Update href. update_href(); diff --git a/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp b/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp index 8d9e7ac8293..d94c60f3cd0 100644 --- a/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp @@ -210,10 +210,10 @@ Optional strip_url_for_use_as_referrer(Optional url, OriginO return {}; // 3. Set url’s username to the empty string. - MUST(url->set_username(""sv)); + url->set_username(""sv); // 4. Set url’s password to the empty string. - MUST(url->set_password(""sv)); + url->set_password(""sv); // 5. Set url’s fragment to null. url->set_fragment({}); diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 76c90095a1d..09185170497 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -495,10 +495,10 @@ WebIDL::ExceptionOr XMLHttpRequest::open(String const& method_string, Stri if (!parsed_url.host().has()) { // 1. If the username argument is not null, set the username given parsedURL and username. if (username.has_value()) - MUST(parsed_url.set_username(username.value())); + parsed_url.set_username(username.value()); // 2. If the password argument is not null, set the password given parsedURL and password. if (password.has_value()) - MUST(parsed_url.set_password(password.value())); + parsed_url.set_password(password.value()); } // 9. If async is false, the current global object is a Window object, and either this’s timeout is