mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +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
3 changed files with 14 additions and 2 deletions
|
@ -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())
|
if (code_point == '%' && !remaining_starts_with_two_ascii_hex_digits())
|
||||||
report_validation_error();
|
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);
|
buffer.append_code_point(code_point);
|
||||||
} else {
|
} 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();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -48,3 +48,13 @@ port => '0'
|
||||||
pathname => ''
|
pathname => ''
|
||||||
search => ''
|
search => ''
|
||||||
hash => ''
|
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:0:1:0:1:0:1:0]',
|
||||||
'http://[1:1:0:0:1:0:0:0]/',
|
'http://[1:1:0:0:1:0:0:0]/',
|
||||||
'unknown://serenityos.org:0',
|
'unknown://serenityos.org:0',
|
||||||
|
'http://serenityos.org/cat?dog#meow"woof',
|
||||||
]) {
|
]) {
|
||||||
printURL(url);
|
printURL(url);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue