diff --git a/AK/URLParser.cpp b/AK/URLParser.cpp index 82a2c98bd3..5119ec5a6f 100644 --- a/AK/URLParser.cpp +++ b/AK/URLParser.cpp @@ -670,7 +670,7 @@ constexpr bool is_double_dot_path_segment(StringView input) } // https://url.spec.whatwg.org/#string-percent-encode-after-encoding -DeprecatedString URLParser::percent_encode_after_encoding(StringView input, URL::PercentEncodeSet percent_encode_set, bool space_as_plus) +ErrorOr URLParser::percent_encode_after_encoding(StringView input, URL::PercentEncodeSet percent_encode_set, bool space_as_plus) { // NOTE: This is written somewhat ad-hoc since we don't yet implement the Encoding spec. @@ -701,7 +701,7 @@ DeprecatedString URLParser::percent_encode_after_encoding(StringView input, URL: } // 6. Return output. - return output.to_deprecated_string(); + return output.to_string(); } // https://url.spec.whatwg.org/#concept-basic-url-parser @@ -1597,7 +1597,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, auto query_percent_encode_set = url->is_special() ? URL::PercentEncodeSet::SpecialQuery : URL::PercentEncodeSet::Query; // 2. Percent-encode after encoding, with encoding, buffer, and queryPercentEncodeSet, and append the result to url’s query. - url->m_query = String::from_deprecated_string(percent_encode_after_encoding(buffer.string_view(), query_percent_encode_set)).release_value_but_fixme_should_propagate_errors(); + url->m_query = percent_encode_after_encoding(buffer.string_view(), query_percent_encode_set).release_value_but_fixme_should_propagate_errors(); // 3. Set buffer to the empty string. buffer.clear(); @@ -1639,7 +1639,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, // NOTE: The percent-encode is done on EOF on the entire buffer. buffer.append_code_point(code_point); } else { - url->m_fragment = String::from_deprecated_string(percent_encode_after_encoding(buffer.string_view(), URL::PercentEncodeSet::Fragment)).release_value_but_fixme_should_propagate_errors(); + url->m_fragment = percent_encode_after_encoding(buffer.string_view(), URL::PercentEncodeSet::Fragment).release_value_but_fixme_should_propagate_errors(); buffer.clear(); } break; diff --git a/AK/URLParser.h b/AK/URLParser.h index 31149d0aaa..de6f945761 100644 --- a/AK/URLParser.h +++ b/AK/URLParser.h @@ -59,7 +59,7 @@ public: static URL basic_parse(StringView input, Optional const& base_url = {}, Optional url = {}, Optional state_override = {}); // https://url.spec.whatwg.org/#string-percent-encode-after-encoding - static DeprecatedString percent_encode_after_encoding(StringView input, URL::PercentEncodeSet percent_encode_set, bool space_as_plus = false); + static ErrorOr percent_encode_after_encoding(StringView input, URL::PercentEncodeSet percent_encode_set, bool space_as_plus = false); // https://url.spec.whatwg.org/#concept-host-serializer static ErrorOr serialize_host(URL::Host const&); diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp index 9c4401c4ed..97b2893918 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp @@ -53,11 +53,11 @@ ErrorOr url_encode(Vector const& tuples, StringView encoding // 2. Let name be the result of running percent-encode after encoding with encoding, tuple’s name, the application/x-www-form-urlencoded percent-encode set, and true. // FIXME: URLParser does not currently implement encoding. - auto name = AK::URLParser::percent_encode_after_encoding(tuple.name, AK::URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true); + auto name = TRY(URLParser::percent_encode_after_encoding(tuple.name, AK::URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true)); // 3. Let value be the result of running percent-encode after encoding with encoding, tuple’s value, the application/x-www-form-urlencoded percent-encode set, and true. // FIXME: URLParser does not currently implement encoding. - auto value = AK::URLParser::percent_encode_after_encoding(tuple.value, AK::URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true); + auto value = TRY(URLParser::percent_encode_after_encoding(tuple.value, AK::URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true)); // 4. If output is not the empty string, then append U+0026 (&) to output. if (!output.is_empty())