Fixed conversion of embedded IPv4 addresses
authorAlexander Ebert <ebert@woltlab.com>
Mon, 5 Aug 2013 00:20:46 +0000 (02:20 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 5 Aug 2013 00:20:46 +0000 (02:20 +0200)
wcfsetup/install/files/lib/util/UserUtil.class.php

index c05a05a31dabd831b2810ef28d563b2ea9b973d2..1c2892822dcf2e1e61309cac2d4fef4c707eeb7f 100644 (file)
@@ -143,6 +143,7 @@ final class UserUtil {
                $ipArray = array_pad(explode('.', $ip), 4, 0);
                $part7 = base_convert(($ipArray[0] * 256) + $ipArray[1], 10, 16);
                $part8 = base_convert(($ipArray[2] * 256) + $ipArray[3], 10, 16);
+               
                return '::ffff:'.$part7.':'.$part8;
        }
        
@@ -167,7 +168,7 @@ final class UserUtil {
                // check if ip is a masked IPv4 address
                if (substr($ip, 0, 7) == '::ffff:') {
                        $ip = substr($ip, 7);
-                       if (preg_match('~^([a-f0-9]{4}):([a-f0-9]{4})$~', $ip, $matches)) {
+                       if (preg_match('~^([a-f0-9]{1,4}):([a-f0-9]{1,4})$~', $ip, $matches)) {
                                $ip = array(
                                        base_convert($matches[1], 16, 10),
                                        base_convert($matches[2], 16, 10)