Make WordPress Core


Ignore:
Timestamp:
10/10/2021 12:12:03 AM (5 years ago)
Author:
SergeyBiryukov
Message:

External Libraries: Update getID3 to version 1.9.21.

The latest version includes preliminary PHP 8.1 support, as well as a variety of bug fixes.

Release notes: https://github.com/JamesHeinrich/getID3/releases/tag/v1.9.21

A full list of changes in this update can be found on GitHub:
https://github.com/JamesHeinrich/getID3/compare/v1.9.20...v1.9.21

This commit also includes PHPCS adjustments previously made for a passing PHP Compatibility scan.

Follow-up to [47601], [47737], [47902], [48278], [49621], [50714].

Props jrf, SergeyBiryukov.
Fixes #54162.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ID3/getid3.lib.php

    r50714 r51900  
    243243         * ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
    244244         *
    245          * @link http://www.psc.edu/general/software/packages/ieee/ieee.html
     245         * @link https://web.archive.org/web/20120325162206/http://www.psc.edu/general/software/packages/ieee/ieee.php
    246246         * @link http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
    247247         *
     
    295295                if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
    296296                        // Not a Number
    297                         $floatvalue = false;
     297                        $floatvalue = NAN;
    298298                } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
    299299                        if ($signbit == '1') {
    300                                 $floatvalue = '-infinity';
     300                                $floatvalue = -INF;
    301301                        } else {
    302                                 $floatvalue = '+infinity';
     302                                $floatvalue = INF;
    303303                        }
    304304                } elseif (($exponent == 0) && ($fraction == 0)) {
     
    428428         */
    429429        public static function Dec2Bin($number) {
     430                if (!is_numeric($number)) {
     431                        // https://github.com/JamesHeinrich/getID3/issues/299
     432                        trigger_error('TypeError: Dec2Bin(): Argument #1 ($number) must be numeric, '.gettype($number).' given', E_USER_WARNING);
     433                        return '';
     434                }
     435                $bytes = array();
    430436                while ($number >= 256) {
    431                         $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
     437                        $bytes[] = (int) (($number / 256) - (floor($number / 256))) * 256;
    432438                        $number = floor($number / 256);
    433439                }
    434                 $bytes[] = $number;
     440                $bytes[] = (int) $number;
    435441                $binstring = '';
    436                 for ($i = 0; $i < count($bytes); $i++) {
    437                         $binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;
     442                foreach ($bytes as $i => $byte) {
     443                        $binstring = (($i == count($bytes) - 1) ? decbin($byte) : str_pad(decbin($byte), 8, '0', STR_PAD_LEFT)).$binstring;
    438444                }
    439445                return $binstring;
     
    666672                //   $foo['path']['to']['my'] = 'file.txt';
    667673                $ArrayPath = ltrim($ArrayPath, $Separator);
     674                $ReturnedArray = array();
    668675                if (($pos = strpos($ArrayPath, $Separator)) !== false) {
    669676                        $ReturnedArray[substr($ArrayPath, 0, $pos)] = self::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
     
    15391546                // Copy all entries from ['tags'] into common ['comments']
    15401547                if (!empty($ThisFileInfo['tags'])) {
    1541                         if (isset($ThisFileInfo['tags']['id3v1'])) {
    1542                                 // bubble ID3v1 to the end, if present to aid in detecting bad ID3v1 encodings
    1543                                 $ID3v1 = $ThisFileInfo['tags']['id3v1'];
    1544                                 unset($ThisFileInfo['tags']['id3v1']);
    1545                                 $ThisFileInfo['tags']['id3v1'] = $ID3v1;
    1546                                 unset($ID3v1);
     1548
     1549                        // Some tag types can only support limited character sets and may contain data in non-standard encoding (usually ID3v1)
     1550                        // and/or poorly-transliterated tag values that are also in tag formats that do support full-range character sets
     1551                        // To make the output more user-friendly, process the potentially-problematic tag formats last to enhance the chance that
     1552                        // the first entries in [comments] are the most correct and the "bad" ones (if any) come later.
     1553                        // https://github.com/JamesHeinrich/getID3/issues/338
     1554                        $processLastTagTypes = array('id3v1','riff');
     1555                        foreach ($processLastTagTypes as $processLastTagType) {
     1556                                if (isset($ThisFileInfo['tags'][$processLastTagType])) {
     1557                                        // bubble ID3v1 to the end, if present to aid in detecting bad ID3v1 encodings
     1558                                        $temp = $ThisFileInfo['tags'][$processLastTagType];
     1559                                        unset($ThisFileInfo['tags'][$processLastTagType]);
     1560                                        $ThisFileInfo['tags'][$processLastTagType] = $temp;
     1561                                        unset($temp);
     1562                                }
    15471563                        }
    15481564                        foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
     
    15631579                                                                                break 2;
    15641580                                                                        }
    1565                                                                 }
    1566                                                                 if (function_exists('mb_convert_encoding')) {
    1567                                                                         if (trim($value) == trim(substr(mb_convert_encoding($existingvalue, $ThisFileInfo['id3v1']['encoding'], $ThisFileInfo['encoding']), 0, 30))) {
    1568                                                                                 // value stored in ID3v1 appears to be probably the multibyte value transliterated (badly) into ISO-8859-1 in ID3v1.
    1569                                                                                 // As an example, Foobar2000 will do this if you tag a file with Chinese or Arabic or Cyrillic or something that doesn't fit into ISO-8859-1 the ID3v1 will consist of mostly "?" characters, one per multibyte unrepresentable character
    1570                                                                                 break 2;
     1581
     1582                                                                        if (function_exists('mb_convert_encoding')) {
     1583                                                                                if (trim($value) == trim(substr(mb_convert_encoding($existingvalue, $ThisFileInfo['id3v1']['encoding'], $ThisFileInfo['encoding']), 0, 30))) {
     1584                                                                                        // value stored in ID3v1 appears to be probably the multibyte value transliterated (badly) into ISO-8859-1 in ID3v1.
     1585                                                                                        // As an example, Foobar2000 will do this if you tag a file with Chinese or Arabic or Cyrillic or something that doesn't fit into ISO-8859-1 the ID3v1 will consist of mostly "?" characters, one per multibyte unrepresentable character
     1586                                                                                        break 2;
     1587                                                                                }
    15711588                                                                        }
    15721589                                                                }
     
    15741591                                                        } elseif (!is_array($value)) {
    15751592
    1576                                                                 $newvaluelength = strlen(trim($value));
     1593                                                                $newvaluelength   =    strlen(trim($value));
     1594                                                                $newvaluelengthMB = mb_strlen(trim($value));
    15771595                                                                foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
    1578                                                                         $oldvaluelength = strlen(trim($existingvalue));
     1596                                                                        $oldvaluelength   =    strlen(trim($existingvalue));
     1597                                                                        $oldvaluelengthMB = mb_strlen(trim($existingvalue));
     1598                                                                        if (($newvaluelengthMB == $oldvaluelengthMB) && ($existingvalue == getid3_lib::iconv_fallback('UTF-8', 'ASCII', $value))) {
     1599                                                                                // https://github.com/JamesHeinrich/getID3/issues/338
     1600                                                                                // check for tags containing extended characters that may have been forced into limited-character storage (e.g. UTF8 values into ASCII)
     1601                                                                                // which will usually display unrepresentable characters as "?"
     1602                                                                                $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
     1603                                                                                break;
     1604                                                                        }
    15791605                                                                        if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
    15801606                                                                                $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
     
    16021628
    16031629                        // attempt to standardize spelling of returned keys
    1604                         $StandardizeFieldNames = array(
    1605                                 'tracknumber' => 'track_number',
    1606                                 'track'       => 'track_number',
    1607                         );
    1608                         foreach ($StandardizeFieldNames as $badkey => $goodkey) {
    1609                                 if (array_key_exists($badkey, $ThisFileInfo['comments']) && !array_key_exists($goodkey, $ThisFileInfo['comments'])) {
    1610                                         $ThisFileInfo['comments'][$goodkey] = $ThisFileInfo['comments'][$badkey];
    1611                                         unset($ThisFileInfo['comments'][$badkey]);
     1630                        if (!empty($ThisFileInfo['comments'])) {
     1631                                $StandardizeFieldNames = array(
     1632                                        'tracknumber' => 'track_number',
     1633                                        'track'       => 'track_number',
     1634                                );
     1635                                foreach ($StandardizeFieldNames as $badkey => $goodkey) {
     1636                                        if (array_key_exists($badkey, $ThisFileInfo['comments']) && !array_key_exists($goodkey, $ThisFileInfo['comments'])) {
     1637                                                $ThisFileInfo['comments'][$goodkey] = $ThisFileInfo['comments'][$badkey];
     1638                                                unset($ThisFileInfo['comments'][$badkey]);
     1639                                        }
    16121640                                }
    16131641                        }
     
    17351763         */
    17361764        public static function getFileSizeSyscall($path) {
     1765                $commandline = null;
    17371766                $filesize = false;
    17381767
     
    17961825         * @return string
    17971826         */
    1798         public static function mb_basename($path, $suffix = null) {
     1827        public static function mb_basename($path, $suffix = '') {
    17991828                $splited = preg_split('#/#', rtrim($path, '/ '));
    18001829                return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
Note: See TracChangeset for help on using the changeset viewer.