mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-02 22:24:26 +00:00
AK: Percent encode URL fragments when parsed
This fixes URL fragments containing characters in the fragment encoding set that were not being correctly percent encoded.
This commit is contained in:
parent
4eab37f391
commit
cb4c279e90
|
@ -1635,10 +1635,11 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> 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;
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue