Răsfoiți Sursa

chore: upgrading ip-lib to 1.22.1

El RIDO 1 lună în urmă
părinte
comite
46f517fee0

+ 1 - 0
CHANGELOG.md

@@ -9,6 +9,7 @@
 * CHANGED: Added a `jsconfig.json` in order to check the types of JavaScript.
 * CHANGED: Removed support for Bootstrap 3 as it requires jQuery.
 * CHANGED: Encode documents with `TextEncoder` in `compress()`, instead of the `utf16To8()` percent-encoding round trip, which allocated ~20 times the payload
+* CHANGED: Upgrading libraries to: ip-lib 1.22.1
 * FIXED: Decode decompressed documents with `TextDecoder` instead of `utf8To16()`, which allocated ~3.4 GB for a 100 MB document and killed the tab (#2027)
 * FIXED: Prevent browsers guessing MIME types on JSON(LD) API responses (#164)
 * FIXED: Insert quoted base path into JSON-LD documents

+ 9 - 9
composer.lock

@@ -396,16 +396,16 @@
         },
         {
             "name": "nikic/php-parser",
-            "version": "v5.8.0",
+            "version": "v5.9.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/nikic/PHP-Parser.git",
-                "reference": "044a6a392ff8ad0d61f14370a5fbbd0a0107152f"
+                "reference": "9e33da9553fe7786f0962b35f4e4ecf01be89def"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/044a6a392ff8ad0d61f14370a5fbbd0a0107152f",
-                "reference": "044a6a392ff8ad0d61f14370a5fbbd0a0107152f",
+                "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/9e33da9553fe7786f0962b35f4e4ecf01be89def",
+                "reference": "9e33da9553fe7786f0962b35f4e4ecf01be89def",
                 "shasum": ""
             },
             "require": {
@@ -447,9 +447,9 @@
             ],
             "support": {
                 "issues": "https://github.com/nikic/PHP-Parser/issues",
-                "source": "https://github.com/nikic/PHP-Parser/tree/v5.8.0"
+                "source": "https://github.com/nikic/PHP-Parser/tree/v5.9.0"
             },
-            "time": "2026-07-04T14:30:18+00:00"
+            "time": "2026-09-13T18:51:52+00:00"
         },
         {
             "name": "phar-io/manifest",
@@ -2047,15 +2047,15 @@
     ],
     "aliases": [],
     "minimum-stability": "stable",
-    "stability-flags": {},
+    "stability-flags": [],
     "prefer-stable": false,
     "prefer-lowest": false,
     "platform": {
         "php": "^7.4 || ^8.0"
     },
-    "platform-dev": {},
+    "platform-dev": [],
     "platform-overrides": {
         "php": "7.4"
     },
-    "plugin-api-version": "2.9.0"
+    "plugin-api-version": "2.3.0"
 }

+ 5 - 5
vendor/composer/installed.php

@@ -3,7 +3,7 @@
         'name' => 'privatebin/privatebin',
         'pretty_version' => 'dev-master',
         'version' => 'dev-master',
-        'reference' => 'cdfce1701ec2b2c197bd1c43c72e79b21339b8ff',
+        'reference' => '07c71be780ccd004802a0294747759af272efc98',
         'type' => 'project',
         'install_path' => __DIR__ . '/../../',
         'aliases' => array(),
@@ -20,9 +20,9 @@
             'dev_requirement' => false,
         ),
         'mlocati/ip-lib' => array(
-            'pretty_version' => '1.22.0',
-            'version' => '1.22.0.0',
-            'reference' => '4e40ffd3bf9989db19403d89c4d8be44b87b8a91',
+            'pretty_version' => '1.22.1',
+            'version' => '1.22.1.0',
+            'reference' => 'f096c0e9ec8bd4691ee45394cfb77c97c6bba272',
             'type' => 'library',
             'install_path' => __DIR__ . '/../mlocati/ip-lib',
             'aliases' => array(),
@@ -31,7 +31,7 @@
         'privatebin/privatebin' => array(
             'pretty_version' => 'dev-master',
             'version' => 'dev-master',
-            'reference' => 'cdfce1701ec2b2c197bd1c43c72e79b21339b8ff',
+            'reference' => '07c71be780ccd004802a0294747759af272efc98',
             'type' => 'project',
             'install_path' => __DIR__ . '/../../',
             'aliases' => array(),

+ 3 - 3
vendor/mlocati/ip-lib/src/Address/IPv4.php

@@ -126,7 +126,7 @@ class IPv4 implements AddressInterface
         $flags = (int) $flags;
         $matches = null;
         if ($flags & ParseStringFlag::ADDRESS_MAYBE_RDNS) {
-            if (preg_match('/^([12]?[0-9]{1,2}\.[12]?[0-9]{1,2}\.[12]?[0-9]{1,2}\.[12]?[0-9]{1,2})\.in-addr\.arpa\.?$/i', $address, $matches)) {
+            if (preg_match('/^([12]?[0-9]{1,2}\.[12]?[0-9]{1,2}\.[12]?[0-9]{1,2}\.[12]?[0-9]{1,2})\.in-addr\.arpa\.?$/Di', $address, $matches)) {
                 $address = implode('.', array_reverse(explode('.', $matches[1])));
                 $flags = $flags & ~(ParseStringFlag::IPV4_MAYBE_NON_DECIMAL | ParseStringFlag::IPV4ADDRESS_MAYBE_NON_QUAD_DOTTED);
             }
@@ -162,7 +162,7 @@ class IPv4 implements AddressInterface
         if ($flags & ParseStringFlag::MAY_INCLUDE_PORT) {
             $rx .= '(?::\d+)?';
         }
-        if (!preg_match('/^' . $rx . '$/', $address, $matches)) {
+        if (!preg_match('/^' . $rx . '$/D', $address, $matches)) {
             return null;
         }
         $math = new \IPLib\Service\UnsignedIntegerMath();
@@ -535,7 +535,7 @@ class IPv4 implements AddressInterface
         }
         $absBits = abs($bits);
         if ($absBits >= 32) {
-            return new self('0.0.0.0');
+            return new static('0.0.0.0');
         }
         $pad = str_repeat('0', $absBits);
         $paddedBits = $this->getBits();

+ 5 - 5
vendor/mlocati/ip-lib/src/Address/IPv6.php

@@ -136,7 +136,7 @@ class IPv6 implements AddressInterface
         $matches = null;
         $flags = (int) $flags;
         if ($flags & ParseStringFlag::ADDRESS_MAYBE_RDNS) {
-            if (preg_match('/^([0-9a-f](?:\.[0-9a-f]){31})\.ip6\.arpa\.?/i', $address, $matches)) {
+            if (preg_match('/^([0-9a-f](?:\.[0-9a-f]){31})\.ip6\.arpa\.?$/Di', $address, $matches)) {
                 $nibbles = array_reverse(explode('.', $matches[1]));
                 $quibbles = array();
                 foreach (array_chunk($nibbles, 4) as $n) {
@@ -147,7 +147,7 @@ class IPv6 implements AddressInterface
         }
         $result = null;
         if (strpos($address, ':') !== false && strpos($address, ':::') === false) {
-            if ($flags & ParseStringFlag::MAY_INCLUDE_PORT && $address[0] === '[' && preg_match('/^\[(.+)]:\d+$/', $address, $matches)) {
+            if ($flags & ParseStringFlag::MAY_INCLUDE_PORT && $address[0] === '[' && preg_match('/^\[(.+)]:\d+$/D', $address, $matches)) {
                 $address = $matches[1];
             }
             if ($flags & ParseStringFlag::MAY_INCLUDE_ZONEID) {
@@ -156,7 +156,7 @@ class IPv6 implements AddressInterface
                     $address = substr($address, 0, $percentagePos);
                 }
             }
-            if (preg_match('/^((?:[0-9a-f]*:+)+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i', $address, $matches)) {
+            if (preg_match('/^((?:[0-9a-f]*:+)+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/Di', $address, $matches)) {
                 $address6 = static::parseString($matches[1] . '0:0');
                 if ($address6 !== null) {
                     $address4 = IPv4::parseString($matches[2]);
@@ -188,7 +188,7 @@ class IPv6 implements AddressInterface
                 if (count($chunks) === 8) {
                     $nums = array_map(
                         function ($chunk) {
-                            return preg_match('/^[0-9A-Fa-f]{1,4}$/', $chunk) ? hexdec($chunk) : false;
+                            return preg_match('/^[0-9A-Fa-f]{1,4}$/D', $chunk) ? hexdec($chunk) : false;
                         },
                         $chunks
                     );
@@ -629,7 +629,7 @@ class IPv6 implements AddressInterface
         }
         $absBits = abs($bits);
         if ($absBits >= 128) {
-            return new self('0000:0000:0000:0000:0000:0000:0000:0000');
+            return new static('0000:0000:0000:0000:0000:0000:0000:0000');
         }
         $pad = str_repeat('0', $absBits);
         $paddedBits = $this->getBits();

+ 8 - 2
vendor/mlocati/ip-lib/src/Range/AbstractRange.php

@@ -26,12 +26,18 @@ abstract class AbstractRange implements RangeInterface
         // @phpstan-ignore varTag.nativeType
         if ($this->rangeType === null) {
             $addressType = $this->getAddressType();
-            if ($addressType === AddressType::T_IPv6 && Subnet::get6to4()->containsRange($this)) {
+            $fromIPv4 = $toIPv4 = null;
+            if ($addressType === AddressType::T_IPv6) {
                 $fromAddress = $this->fromAddress;
                 /** @var IPv6 $fromAddress */
                 $toAddress = $this->toAddress;
                 /** @var IPv6 $toAddress */
-                $range = Factory::getRangeFromBoundaries($fromAddress->toIPv4(), $toAddress->toIPv4());
+                // 6to4 and IPv4-mapped ranges: use the type of the corresponding IPv4 range
+                $fromIPv4 = $fromAddress->toIPv4();
+                $toIPv4 = $toAddress->toIPv4();
+            }
+            if ($fromIPv4 !== null && $toIPv4 !== null) {
+                $range = Factory::getRangeFromBoundaries($fromIPv4, $toIPv4);
                 /** @var RangeInterface $range */
                 $this->rangeType = $range->getRangeType();
             } else {

+ 15 - 11
vendor/mlocati/ip-lib/src/Range/Pattern.php

@@ -124,7 +124,7 @@ class Pattern extends AbstractRange
             return new static($fromAddress, $toAddress, 8);
         }
         $matches = null;
-        if (strpos($range, '.') !== false && preg_match('/^[^*]+((?:\.\*)+)$/', $range, $matches)) {
+        if (strpos($range, '.') !== false && preg_match('/^[^*]+((?:\.\*)+)$/D', $range, $matches)) {
             $asterisksCount = strlen($matches[1]) >> 1;
             if ($asterisksCount > 0) {
                 $missingDots = 3 - substr_count($range, '.');
@@ -144,9 +144,9 @@ class Pattern extends AbstractRange
 
             return new static($fromAddress, $toAddress, $asterisksCount);
         }
-        if (strpos($range, ':') !== false && preg_match('/^[^*]+((?::\*)+)$/', $range, $matches)) {
+        if (strpos($range, ':') !== false && preg_match('/^[^*]+((?::\*)+)$/D', $range, $matches)) {
             $asterisksCount = strlen($matches[1]) >> 1;
-            $fromAddress = IPv6::parseString(str_replace('*', '0', $range));
+            $fromAddress = IPv6::parseString(str_replace('*', '0', $range), $flags);
             if ($fromAddress === null) {
                 return null;
             }
@@ -187,17 +187,21 @@ class Pattern extends AbstractRange
                 } elseif ($this->asterisksCount === 8) {
                     $result = '*:*:*:*:*:*:*:*';
                 } else {
-                    $bytes = $this->toAddress->getBytes();
-                    $bytes = array_slice($bytes, 0, -$this->asterisksCount * 2);
-                    $bytes = array_pad($bytes, 16, 1);
-                    $address = IPv6::fromBytes($bytes);
-                    /** @var IPv6 $address */
-                    $before = substr($address->toString(false), 0, -strlen(':101') * $this->asterisksCount);
-                    $result = $before . str_repeat(':*', $this->asterisksCount);
+                    $numFixedWords = 8 - $this->asterisksCount;
+                    $chunks = array_map('dechex', array_slice($this->fromAddress->getWords(), 0, $numFixedWords));
+                    $result = implode(':', array_pad($chunks, 8, '*'));
+                    $matches = null;
+                    for ($i = $numFixedWords; $i > 1; $i--) {
+                        $search = '(?:^|:)' . rtrim(str_repeat('0:', $i), ':') . ':';
+                        if (preg_match('/^(.*?)' . $search . '(.*)$/', $result, $matches)) {
+                            $result = $matches[1] . '::' . $matches[2];
+                            break;
+                        }
+                    }
                 }
                 break;
             default:
-                throw new \Exception('@todo'); // @codeCoverageIgnore
+                throw new \RuntimeException('Unsupported address type: ' . get_class($this->fromAddress)); // @codeCoverageIgnore
         }
 
         return $result;

+ 3 - 6
vendor/mlocati/ip-lib/src/Range/Single.php

@@ -256,11 +256,8 @@ class Single extends AbstractRange
      */
     public function getNetworkPrefix()
     {
-        switch ($this->getAddressType()) {
-            case AddressType::T_IPv4:
-                return 32;
-            case AddressType::T_IPv6:
-                return 128;
-        }
+        $address = $this->address;
+
+        return $address::getNumberOfBits();
     }
 }

+ 6 - 6
vendor/mlocati/ip-lib/src/Range/Subnet.php

@@ -43,7 +43,7 @@ class Subnet extends AbstractRange
     /**
      * The type of the range of this IP range.
      *
-     * @var int|null
+     * @var int|false|null false if this range crosses multiple range types, null if yet to be determined
      *
      * @since 1.5.0
      */
@@ -131,7 +131,7 @@ class Subnet extends AbstractRange
         if ($address === null) {
             return null;
         }
-        if (!preg_match('/^[0-9]{1,9}$/', $parts[1])) {
+        if (!preg_match('/^[0-9]{1,9}$/D', $parts[1])) {
             return null;
         }
         $networkPrefix = (int) $parts[1];
@@ -237,13 +237,13 @@ class Subnet extends AbstractRange
      */
     public function asPattern()
     {
-        $address = $this->getStartAddress();
+        $startAddress = $this->getStartAddress();
         $networkPrefix = $this->getNetworkPrefix();
-        switch ($address->getAddressType()) {
+        switch ($startAddress->getAddressType()) {
             case AddressType::T_IPv4:
-                return $networkPrefix % 8 === 0 ? new Pattern($address, $address, 4 - $networkPrefix / 8) : null;
+                return $networkPrefix % 8 === 0 ? new Pattern($startAddress, $this->getEndAddress(), 4 - $networkPrefix / 8) : null;
             case AddressType::T_IPv6:
-                return $networkPrefix % 16 === 0 ? new Pattern($address, $address, 8 - $networkPrefix / 16) : null;
+                return $networkPrefix % 16 === 0 ? new Pattern($startAddress, $this->getEndAddress(), 8 - $networkPrefix / 16) : null;
         }
     }
 

+ 4 - 4
vendor/mlocati/ip-lib/src/Range/Type.php

@@ -50,7 +50,7 @@ class Type
     const T_LIMITEDBROADCAST = 6;
 
     /**
-     * Multicast address assignments - Indentify a group of interfaces.
+     * Multicast address assignments - Identify a group of interfaces.
      *
      * @var int
      */
@@ -64,7 +64,7 @@ class Type
     const T_LINKLOCAL = 8;
 
     /**
-     * Link local unicast / Linked-scoped unicast.
+     * Link local unicast / Link-scoped unicast.
      *
      * @var int
      */
@@ -130,11 +130,11 @@ class Type
             case static::T_LIMITEDBROADCAST:
                 return '"Limited broadcast" destination address';
             case static::T_MULTICAST:
-                return 'Multicast address assignments - Indentify a group of interfaces';
+                return 'Multicast address assignments - Identify a group of interfaces';
             case static::T_LINKLOCAL:
                 return '"Link local" address, allocated for communication between hosts on a single link';
             case static::T_LINKLOCAL_UNICAST:
-                return 'Link local unicast / Linked-scoped unicast';
+                return 'Link local unicast / Link-scoped unicast';
             case static::T_DISCARDONLY:
                 return 'Discard only';
             case static::T_DISCARD:

+ 3 - 3
vendor/mlocati/ip-lib/src/Service/BinaryMath.php

@@ -46,7 +46,7 @@ class BinaryMath
      * @param string $a
      * @param string $b
      *
-     * @return int 1 if $a is greater than $b, -1 if $b is greater than $b, 0 if they are the same
+     * @return int 1 if $a is greater than $b, -1 if $b is greater than $a, 0 if they are the same
      */
     public function compare($a, $b)
     {
@@ -162,7 +162,7 @@ class BinaryMath
             $value = substr($value, 1);
         }
         $matches = null;
-        if (!preg_match('/^0*([0-9]+)$/', $value, $matches)) {
+        if (!preg_match('/^0*([0-9]+)$/D', $value, $matches)) {
             return '';
         }
         $numericString = $matches[1];
@@ -229,7 +229,7 @@ class BinaryMath
      * @param string $num1
      * @param string $num2
      *
-     * @return array{string, string, int} The first array element is $num1 (padded), the first array element is $num2 (padded), the third array element is the number of bits
+     * @return array{string, string, int} The first array element is $num1 (padded), the second array element is $num2 (padded), the third array element is the number of bits
      */
     private function toSameLength($num1, $num2)
     {

+ 1 - 3
vendor/mlocati/ip-lib/src/Service/NumberInChunks.php

@@ -43,8 +43,6 @@ class NumberInChunks
     }
 
     /**
-     * @throws \InvalidArgumentException if $other has a $chunkSize that's not the same as the $chunkSize of this
-     *
      * @return \IPLib\Service\NumberInChunks
      */
     public function negate()
@@ -53,7 +51,7 @@ class NumberInChunks
     }
 
     /**
-     * @throws \InvalidArgumentException if $other has a $chunkSize that's not the same as the $chunkSize of this
+     * @throws \InvalidArgumentException if $that has a $chunkSize that's not the same as the $chunkSize of this
      *
      * @return \IPLib\Service\NumberInChunks
      */

+ 4 - 4
vendor/mlocati/ip-lib/src/Service/UnsignedIntegerMath.php

@@ -22,17 +22,17 @@ class UnsignedIntegerMath
     {
         $m = null;
         if ($onlyDecimal) {
-            if (preg_match('/^0*(\d+)$/', $value, $m)) {
+            if (preg_match('/^0*(\d+)$/D', $value, $m)) {
                 return $this->getBytesFromDecimal($m[1], $numBytes);
             }
         } else {
-            if (preg_match('/^0[Xx]0*([0-9A-Fa-f]+)$/', $value, $m)) {
+            if (preg_match('/^0[Xx]0*([0-9A-Fa-f]+)$/D', $value, $m)) {
                 return $this->getBytesFromHexadecimal($m[1], $numBytes);
             }
-            if (preg_match('/^0+([0-7]*)$/', $value, $m)) {
+            if (preg_match('/^0+([0-7]*)$/D', $value, $m)) {
                 return $this->getBytesFromOctal($m[1], $numBytes);
             }
-            if (preg_match('/^[1-9][0-9]*$/', $value)) {
+            if (preg_match('/^[1-9][0-9]*$/D', $value)) {
                 return $this->getBytesFromDecimal($value, $numBytes);
             }
         }