Make WordPress Core


Ignore:
Timestamp:
09/26/2022 01:58:53 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Update sodium_compat to v1.19.0.

The latest version of sodium_compat includes improved compatibility with the PHP 8.0 named parameters functionality.

Release notes:
https://github.com/paragonie/sodium_compat/releases/tag/v1.19.0

A full list of changes in this update can be found on GitHub:
https://github.com/paragonie/sodium_compat/compare/v1.18.0...v1.19.0

Follow-up to [49741], [51002], [51591], [52988], [54150].

Props jrf, paragoninitiativeenterprises.
Fixes #56653.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/sodium_compat/src/Core/Util.php

    r52988 r54310  
    310310     *
    311311     * @param string $hexString
     312     * @param string $ignore
    312313     * @param bool $strictPadding
    313314     * @return string (raw binary)
     
    315316     * @throws TypeError
    316317     */
    317     public static function hex2bin($hexString, $strictPadding = false)
     318    public static function hex2bin($hexString, $ignore = '', $strictPadding = false)
    318319    {
    319320        /* Type checks: */
     
    321322            throw new TypeError('Argument 1 must be a string, ' . gettype($hexString) . ' given.');
    322323        }
    323 
    324         /** @var int $hex_pos */
     324        if (!is_string($ignore)) {
     325            throw new TypeError('Argument 2 must be a string, ' . gettype($hexString) . ' given.');
     326        }
     327
    325328        $hex_pos = 0;
    326         /** @var string $bin */
    327329        $bin = '';
    328         /** @var int $c_acc */
    329330        $c_acc = 0;
    330         /** @var int $hex_len */
    331331        $hex_len = self::strlen($hexString);
    332         /** @var int $state */
    333332        $state = 0;
    334333        if (($hex_len & 1) !== 0) {
     
    348347            /** @var int $c */
    349348            $c = $chunk[$hex_pos];
    350             /** @var int $c_num */
    351349            $c_num = $c ^ 48;
    352             /** @var int $c_num0 */
    353350            $c_num0 = ($c_num - 10) >> 8;
    354             /** @var int $c_alpha */
    355351            $c_alpha = ($c & ~32) - 55;
    356             /** @var int $c_alpha0 */
    357352            $c_alpha0 = (($c_alpha - 10) ^ ($c_alpha - 16)) >> 8;
    358353            if (($c_num0 | $c_alpha0) === 0) {
     354                if ($ignore && $state === 0 && strpos($ignore, self::intToChr($c)) !== false) {
     355                    continue;
     356                }
    359357                throw new RangeException(
    360358                    'hex2bin() only expects hexadecimal characters'
    361359                );
    362360            }
    363             /** @var int $c_val */
    364361            $c_val = ($c_num0 & $c_num) | ($c_alpha & $c_alpha0);
    365362            if ($state === 0) {
     
    383380    public static function intArrayToString(array $ints)
    384381    {
    385         /** @var array<int, int> $args */
    386382        $args = $ints;
    387383        foreach ($args as $i => $v) {
Note: See TracChangeset for help on using the changeset viewer.