diff --git a/AK/URLParser.cpp b/AK/URLParser.cpp index c908672f93..82a2c98bd3 100644 --- a/AK/URLParser.cpp +++ b/AK/URLParser.cpp @@ -1635,10 +1635,11 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, if (code_point == '%' && !remaining_starts_with_two_ascii_hex_digits()) report_validation_error(); - // FIXME: 3. UTF-8 percent-encode c using the fragment percent-encode set and append the result to url’s fragment. + // 3. UTF-8 percent-encode c using the fragment percent-encode set and append the result to url’s fragment. + // NOTE: The percent-encode is done on EOF on the entire buffer. buffer.append_code_point(code_point); } else { - url->m_fragment = buffer.to_string().release_value_but_fixme_should_propagate_errors(); + url->m_fragment = String::from_deprecated_string(percent_encode_after_encoding(buffer.string_view(), URL::PercentEncodeSet::Fragment)).release_value_but_fixme_should_propagate_errors(); buffer.clear(); } break; diff --git a/Tests/LibWeb/Text/expected/URL/url.txt b/Tests/LibWeb/Text/expected/URL/url.txt index 05ea1e7f99..5325c1803f 100644 --- a/Tests/LibWeb/Text/expected/URL/url.txt +++ b/Tests/LibWeb/Text/expected/URL/url.txt @@ -48,3 +48,13 @@ port => '0' pathname => '' search => '' hash => '' +http://serenityos.org/cat?dog#meow"woof +protocol => 'http:' +username => '' +password => '' +host => 'serenityos.org' +hostname => 'serenityos.org' +port => '' +pathname => '/cat' +search => '?dog' +hash => '#meow%22woof' diff --git a/Tests/LibWeb/Text/input/URL/url.html b/Tests/LibWeb/Text/input/URL/url.html index 2131563357..b8832fc355 100644 --- a/Tests/LibWeb/Text/input/URL/url.html +++ b/Tests/LibWeb/Text/input/URL/url.html @@ -21,6 +21,7 @@ 'http://[1:0:1:0:1:0:1:0]', 'http://[1:1:0:0:1:0:0:0]/', 'unknown://serenityos.org:0', + 'http://serenityos.org/cat?dog#meow"woof', ]) { printURL(url); }