mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
AK: Fix IPv6 serialization on multiple '0' parts ending in a '0' part
This could happen if a sequence of '0' parts was followed by a longer sequence of '0' parts at the end of the host. The first sequence was being used for the compress, and not the second. For example, [1:1:0:0:1:0:0:0] was being serialized as: [1:1::1:0:0:0] instead of [1:1:0:0:1::]. Fix this by checking at the end of the loop if we are in the middle of a sequence of '0' parts that is longer than the current longest.
This commit is contained in:
parent
7f99f3bf29
commit
faf9d08371
3 changed files with 15 additions and 0 deletions
|
@ -250,6 +250,11 @@ static void serialize_ipv6_address(URL::IPv6Address const& address, StringBuilde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (current_sequence_length > longest_sequence_length) {
|
||||||
|
longest_sequence_length = current_sequence_length;
|
||||||
|
compress = current_sequence_start;
|
||||||
|
}
|
||||||
|
|
||||||
// 3. If there is no sequence of address’s IPv6 pieces that are 0 that is longer than 1, then set compress to null.
|
// 3. If there is no sequence of address’s IPv6 pieces that are 0 that is longer than 1, then set compress to null.
|
||||||
if (longest_sequence_length <= 1)
|
if (longest_sequence_length <= 1)
|
||||||
compress = {};
|
compress = {};
|
||||||
|
|
|
@ -25,3 +25,12 @@ hostname => '[1:0:1:0:1:0:1:0]'
|
||||||
port => ''
|
port => ''
|
||||||
pathname => '/'
|
pathname => '/'
|
||||||
search => ''
|
search => ''
|
||||||
|
http://[1:1:0:0:1:0:0:0]/
|
||||||
|
protocol => 'http:'
|
||||||
|
username => ''
|
||||||
|
password => ''
|
||||||
|
host => '[1:1:0:0:1::]'
|
||||||
|
hostname => '[1:1:0:0:1::]'
|
||||||
|
port => ''
|
||||||
|
pathname => '/'
|
||||||
|
search => ''
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
'ftp://serenityos.org:21',
|
'ftp://serenityos.org:21',
|
||||||
'http://[0:1:0:1:0:1:0:1]',
|
'http://[0:1:0:1:0:1:0:1]',
|
||||||
'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]/',
|
||||||
]) {
|
]) {
|
||||||
printURL(url);
|
printURL(url);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue