AK: Fix missing step step for serialization of IPv6 hosts

This was resulting in the incorrect host serialization of:

http://[0:1:0:1:0:1:0:1] to [::1:0:1:0:1:0:1]

and:

http://[1:0:1:0:1:0:1:0] to [1::1:0:1:0:1:0]
This commit is contained in:
Shannon Booth 2023-07-31 22:57:43 +12:00 committed by Andreas Kling
parent 4fdd4dd979
commit aa7ca80d7c
Notes: sideshowbarker 2024-07-17 02:37:08 +09:00
3 changed files with 25 additions and 1 deletions

View file

@ -232,7 +232,6 @@ static void serialize_ipv6_address(URL::IPv6Address const& address, StringBuilde
// 1. Let output be the empty string.
// 2. Let compress be an index to the first IPv6 piece in the first longest sequences of addresss IPv6 pieces that are 0.
// 3. If there is no sequence of addresss IPv6 pieces that are 0 that is longer than 1, then set compress to null.
Optional<size_t> compress;
size_t longest_sequence_length = 0;
size_t current_sequence_length = 0;
@ -250,6 +249,11 @@ static void serialize_ipv6_address(URL::IPv6Address const& address, StringBuilde
current_sequence_length = 0;
}
}
// 3. If there is no sequence of addresss IPv6 pieces that are 0 that is longer than 1, then set compress to null.
if (longest_sequence_length <= 1)
compress = {};
// 4. Let ignore0 be false.
auto ignore0 = false;

View file

@ -7,3 +7,21 @@ hostname => 'serenityos.org'
port => ''
pathname => '/'
search => ''
http://[0:1:0:1:0:1:0:1]
protocol => 'http:'
username => ''
password => ''
host => '[0:1:0:1:0:1:0:1]'
hostname => '[0:1:0:1:0:1:0:1]'
port => ''
pathname => '/'
search => ''
http://[1:0:1:0:1:0:1:0]
protocol => 'http:'
username => ''
password => ''
host => '[1:0:1:0:1:0:1:0]'
hostname => '[1:0:1:0:1:0:1:0]'
port => ''
pathname => '/'
search => ''

View file

@ -16,6 +16,8 @@
for (url of [
'ftp://serenityos.org:21',
'http://[0:1:0:1:0:1:0:1]',
'http://[1:0:1:0:1:0:1:0]',
]) {
printURL(url);
}