Fix IpAddress::toBulletMasked() for IP addresses with unmasked quadruplets with value...
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 23 Jul 2021 10:33:23 +0000 (12:33 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 23 Jul 2021 10:38:14 +0000 (12:38 +0200)
commitcb18d650563164f49e518ad9d699116b8f75dcf4
treea40cc957e392464be2a4dcd4ec16ee399f6b2573
parent4965b0699180d6a16b631bdf4fa5d13e45a8a474
Fix IpAddress::toBulletMasked() for IP addresses with unmasked quadruplets with value zero

Rebuild the IPv6 masking algorithm to a proper parser handling the quadruplets
one-by-one, instead of attempting to process the IP address using regular
expressions.

This patch fixes masking of IP addresses such as:

    2001:db8:1234:0:abcd::1234

Applying a /64 mask will transform the IP address into:

    2001:db8:1234::

Note how the explicit 0 block is elided as well.

Previously the bullet masking algorithm would transform this into:

    2001:db8:1234:••••:••••:••••:••••

Resulting in an IP address with just 7 quadruplets. Now it correctly returns:

    2001:db8:1234:0:••••:••••:••••:••••
wcfsetup/install/files/lib/util/IpAddress.class.php