Make WordPress Core


Ignore:
Timestamp:
10/10/2021 01:15:16 AM (3 years ago)
Author:
SergeyBiryukov
Message:

External Libraries: Revert [51900] for now to investigate test failures.

See #54162.

File:
1 edited

Legend:

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

    r51900 r51901  
    243243     * ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
    244244     *
    245      * @link https://web.archive.org/web/20120325162206/http://www.psc.edu/general/software/packages/ieee/ieee.php
     245     * @link http://www.psc.edu/general/software/packages/ieee/ieee.html
    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 = NAN;
     297            $floatvalue = false;
    298298        } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
    299299            if ($signbit == '1') {
    300                 $floatvalue = -INF;
     300                $floatvalue = '-infinity';
    301301            } else {
    302                 $floatvalue = INF;
     302                $floatvalue = '+infinity';
    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();
    436430        while ($number >= 256) {
    437             $bytes[] = (int) (($number / 256) - (floor($number / 256))) * 256;
     431            $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
    438432            $number = floor($number / 256);
    439433        }
    440         $bytes[] = (int) $number;
     434        $bytes[] = $number;
    441435        $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;
     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;
    444438        }
    445439        return $binstring;
     
    672666        //   $foo['path']['to']['my'] = 'file.txt';
    673667        $ArrayPath = ltrim($ArrayPath, $Separator);
    674         $ReturnedArray = array();
    675668        if (($pos = strpos($ArrayPath, $Separator)) !== false) {
    676669            $ReturnedArray[substr($ArrayPath, 0, $pos)] = self::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
     
    15461539        // Copy all entries from ['tags'] into common ['comments']
    15471540        if (!empty($ThisFileInfo['tags'])) {
    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                 }
     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);
    15631547            }
    15641548            foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
     
    15791563                                        break 2;
    15801564                                    }
    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                                         }
     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;
    15881571                                    }
    15891572                                }
     
    15911574                            } elseif (!is_array($value)) {
    15921575
    1593                                 $newvaluelength   =    strlen(trim($value));
    1594                                 $newvaluelengthMB = mb_strlen(trim($value));
     1576                                $newvaluelength = strlen(trim($value));
    15951577                                foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $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                                     }
     1578                                    $oldvaluelength = strlen(trim($existingvalue));
    16051579                                    if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
    16061580                                        $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
     
    16281602
    16291603            // attempt to standardize spelling of returned keys
    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                     }
     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]);
    16401612                }
    16411613            }
     
    17631735     */
    17641736    public static function getFileSizeSyscall($path) {
    1765         $commandline = null;
    17661737        $filesize = false;
    17671738
     
    18251796     * @return string
    18261797     */
    1827     public static function mb_basename($path, $suffix = '') {
     1798    public static function mb_basename($path, $suffix = null) {
    18281799        $splited = preg_split('#/#', rtrim($path, '/ '));
    18291800        return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
Note: See TracChangeset for help on using the changeset viewer.