WordPress build repository browser

Changeset 60565


Ignore:
Timestamp:
11/17/2025 10:22:33 PM (7 days ago)
Author:
desrosj
Message:

External Libraries: Update getID3 to version 1.9.24.

In [60812], two changes related to PHP 8.5 compatibility were cherry picked from the upstream repository to be included in time for WordPress 6.9. Since then, a proper release has been tagged which includes several bug fixes in addition to the previous two changes.

HEIF support has also been added to the Quicktime audio/video module.

A full list of changes can be found on GitHub: https://github.com/JamesHeinrich/getID3/releases/tag/v1.9.24

Props TobiasBg.
Fixes #64253.
Built from https://develop.svn.wordpress.org/trunk@61253

Location:
trunk/wp-includes
Files:
11 edited

Legend:

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

    r60148 r60565  
    1212/////////////////////////////////////////////////////////////////
    1313
    14 if(!defined('GETID3_LIBXML_OPTIONS') && defined('LIBXML_VERSION')) {
    15     if(LIBXML_VERSION >= 20621) {
     14if (!defined('GETID3_LIBXML_OPTIONS') && defined('LIBXML_VERSION')) {
     15    if (LIBXML_VERSION >= 20621) {
    1616        define('GETID3_LIBXML_OPTIONS', LIBXML_NOENT | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_COMPACT);
    1717    } else {
     
    7474    /**
    7575     * @param int|null $variable
    76      * @param int      $increment
     76     * @param-out int  $variable
     77     * @param int      $increment
    7778     *
    7879     * @return bool
     
    116117        static $hasINT64 = null;
    117118        if ($hasINT64 === null) { // 10x faster than is_null()
    118             $hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1
     119            /** @var int|float|object $bigInt */
     120            $bigInt = pow(2, 31);
     121            $hasINT64 = is_int($bigInt); // 32-bit int are limited to (2^31)-1
    119122            if (!$hasINT64 && !defined('PHP_INT_MIN')) {
    120123                define('PHP_INT_MIN', ~PHP_INT_MAX);
     
    441444
    442445    /**
    443      * @param int $number
     446     * @param int|string $number
    444447     *
    445448     * @return string
     
    745748     */
    746749    public static function XML2array($XMLstring) {
    747         if (function_exists('simplexml_load_string') && function_exists('libxml_disable_entity_loader')) {
    748             // http://websec.io/2012/08/27/Preventing-XEE-in-PHP.html
    749             // https://core.trac.wordpress.org/changeset/29378
    750             // This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading is
    751             // disabled by default, but is still needed when LIBXML_NOENT is used.
    752             $loader = @libxml_disable_entity_loader(true);
    753             $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', GETID3_LIBXML_OPTIONS);
    754             $return = self::SimpleXMLelement2array($XMLobject);
    755             @libxml_disable_entity_loader($loader);
    756             return $return;
     750        if (function_exists('simplexml_load_string')) {
     751            if (PHP_VERSION_ID < 80000) {
     752                if (function_exists('libxml_disable_entity_loader')) {
     753                    // http://websec.io/2012/08/27/Preventing-XEE-in-PHP.html
     754                    // https://core.trac.wordpress.org/changeset/29378
     755                    // This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading is
     756                    // disabled by default, but is still needed when LIBXML_NOENT is used.
     757                    $loader = @libxml_disable_entity_loader(true);
     758                    $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', GETID3_LIBXML_OPTIONS);
     759                    $return = self::SimpleXMLelement2array($XMLobject);
     760                    @libxml_disable_entity_loader($loader);
     761                    return $return;
     762                }
     763            } else {
     764                $allow = false;
     765                if (defined('LIBXML_VERSION') && (LIBXML_VERSION >= 20900)) {
     766                    // https://www.php.net/manual/en/function.libxml-disable-entity-loader.php
     767                    // "as of libxml 2.9.0 entity substitution is disabled by default, so there is no need to disable the loading
     768                    //  of external entities, unless there is the need to resolve internal entity references with LIBXML_NOENT."
     769                    $allow = true;
     770                } elseif (function_exists('libxml_set_external_entity_loader')) {
     771                    libxml_set_external_entity_loader(function () { return null; }); // https://www.zend.com/blog/cve-2023-3823
     772                    $allow = true;
     773                }
     774                if ($allow) {
     775                    $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', GETID3_LIBXML_OPTIONS);
     776                    $return = self::SimpleXMLelement2array($XMLobject);
     777                    return $return;
     778                }
     779            }
    757780        }
    758781        return false;
     
    14981521        if (PHP_VERSION_ID >= 50400) {
    14991522            $GetDataImageSize = @getimagesizefromstring($imgData, $imageinfo);
    1500             if ($GetDataImageSize === false || !isset($GetDataImageSize[0], $GetDataImageSize[1])) {
     1523            if ($GetDataImageSize === false) {
    15011524                return false;
    15021525            }
     
    15261549                fclose($tmp);
    15271550                $GetDataImageSize = @getimagesize($tempfilename, $imageinfo);
    1528                 if (($GetDataImageSize === false) || !isset($GetDataImageSize[0]) || !isset($GetDataImageSize[1])) {
     1551                if ($GetDataImageSize === false) {
    15291552                    return false;
    15301553                }
     
    17201743            //$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
    17211744            $explodedLine = explode("\t", $line, 2);
    1722             $ThisKey   = (isset($explodedLine[0]) ? $explodedLine[0] : '');
     1745            $ThisKey   = $explodedLine[0];
    17231746            $ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : '');
    17241747            $cache[$file][$name][$ThisKey] = trim($ThisValue);
  • trunk/wp-includes/ID3/getid3.php

    r60148 r60565  
    388388    protected $startup_warning = '';
    389389
    390     const VERSION           = '1.9.23-202310190849';
     390    const VERSION           = '1.9.24-202509040923';
    391391    const FREAD_BUFFER_SIZE = 32768;
    392392
     
    410410        if (preg_match('#([0-9]+) ?M#i', $memoryLimit, $matches)) {
    411411            // could be stored as "16M" rather than 16777216 for example
    412             $memoryLimit = $matches[1] * 1048576;
     412            $memoryLimit = (int) $matches[1] * 1048576;
    413413        } elseif (preg_match('#([0-9]+) ?G#i', $memoryLimit, $matches)) { // The 'G' modifier is available since PHP 5.1.0
    414414            // could be stored as "2G" rather than 2147483648 for example
    415             $memoryLimit = $matches[1] * 1073741824;
     415            $memoryLimit = (int) $matches[1] * 1073741824;
    416416        }
    417417        $this->memory_limit = $memoryLimit;
     
    447447            // Check for magic_quotes_gpc
    448448            if (function_exists('get_magic_quotes_gpc')) {
    449                 if (get_magic_quotes_gpc()) { // @phpstan-ignore-line
     449                if (get_magic_quotes_gpc()) {
    450450                    $this->startup_error .= 'magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).'."\n";
    451451                }
     
    530530     */
    531531    public function setOption($optArray) {
    532         if (!is_array($optArray) || empty($optArray)) {
     532        if (empty($optArray)) {
    533533            return false;
    534534        }
     
    681681                        throw $e;
    682682                    }
     683                } else {
     684                    $this->warning('skipping check for '.$tag_name.' tags since option_tag_'.$tag_name.'=FALSE');
    683685                }
    684686            }
     
    14771479
    14781480                // Misc other formats
     1481
     1482                // GPX - data         - GPS Exchange Format
     1483                'gpx' => array (
     1484                            'pattern'   => '^<\\?xml [^>]+>[\s]*<gpx ',
     1485                            'group'     => 'misc',
     1486                            'module'    => 'gpx',
     1487                            'mime_type' => 'application/gpx+xml',
     1488                            'fail_id3'  => 'ERROR',
     1489                            'fail_ape'  => 'ERROR',
     1490                        ),
    14791491
    14801492                // PAR2 - data        - Parity Volume Set Specification 2.0
     
    18911903        // Calculate combined bitrate - audio + video
    18921904        $CombinedBitrate  = 0;
    1893         $CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);
    1894         $CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);
     1905        $CombinedBitrate += (isset($this->info['audio']['bitrate']) && ($this->info['audio']['bitrate'] != 'free') ? $this->info['audio']['bitrate'] : 0);
     1906        $CombinedBitrate += (isset($this->info['video']['bitrate'])                                                ? $this->info['video']['bitrate'] : 0);
    18951907        if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {
    18961908            $this->info['bitrate'] = $CombinedBitrate;
     
    19992011            return false;
    20002012        }
    2001         $this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
     2013        if ($this->info['audio']['bitrate'] != 'free') {
     2014            $this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
     2015        }
    20022016
    20032017        if (!empty($this->info['audio']['streams'])) {
  • trunk/wp-includes/ID3/module.audio-video.asf.php

    r56486 r60565  
    337337                    $thisfile_asf['codec_list_object'] = array();
    338338                    /** @var mixed[] $thisfile_asf_codeclistobject */
    339                     $thisfile_asf_codeclistobject      = &$thisfile_asf['codec_list_object'];
     339                    $thisfile_asf_codeclistobject      = &$thisfile_asf['codec_list_object']; // @phpstan-ignore-line
    340340
    341341                    $thisfile_asf_codeclistobject['offset']                    = $NextObjectOffset + $offset;
     
    500500                    $thisfile_asf_scriptcommandobject['command_types_count']  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
    501501                    $offset += 2;
    502                     for ($CommandTypesCounter = 0; $CommandTypesCounter < $thisfile_asf_scriptcommandobject['command_types_count']; $CommandTypesCounter++) {
    503                         $CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
    504                         $offset += 2;
    505                         $thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
    506                         $offset += $CommandTypeNameLength;
    507                     }
    508                     for ($CommandsCounter = 0; $CommandsCounter < $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) {
     502                    if ($thisfile_asf_scriptcommandobject['command_types_count'] > 0) {
     503                        $thisfile_asf_scriptcommandobject['command_types'] = array();
     504                        for ($CommandTypesCounter = 0; $CommandTypesCounter < (int) $thisfile_asf_scriptcommandobject['command_types_count']; $CommandTypesCounter++) {
     505                            $CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
     506                            $offset += 2;
     507                            $thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter] = array();
     508                            $thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
     509                            $offset += $CommandTypeNameLength;
     510                        }
     511                    }
     512                    for ($CommandsCounter = 0; $CommandsCounter < (int) $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) {
    509513                        $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['presentation_time']  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
    510514                        $offset += 4;
     
    555559                    }
    556560                    $thisfile_asf_markerobject['markers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
     561                    /** @var int|float|false $totalMakersCount */
     562                    $totalMakersCount = $thisfile_asf_markerobject['markers_count'];
    557563                    $offset += 4;
    558564                    $thisfile_asf_markerobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
     
    566572                    $thisfile_asf_markerobject['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['name_length']);
    567573                    $offset += $thisfile_asf_markerobject['name_length'];
    568                     for ($MarkersCounter = 0; $MarkersCounter < $thisfile_asf_markerobject['markers_count']; $MarkersCounter++) {
     574                    for ($MarkersCounter = 0; $MarkersCounter < $totalMakersCount; $MarkersCounter++) {
     575                        $thisfile_asf_markerobject['markers'][$MarkersCounter] = array();
    569576                        $thisfile_asf_markerobject['markers'][$MarkersCounter]['offset']  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
    570577                        $offset += 8;
     
    616623                    $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
    617624                    $offset += 2;
    618                     for ($StreamNumberCounter = 0; $StreamNumberCounter < $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; $StreamNumberCounter++) {
     625                    for ($StreamNumberCounter = 0; $StreamNumberCounter < (int) $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; $StreamNumberCounter++) {
    619626                        $thisfile_asf_bitratemutualexclusionobject['stream_numbers'][$StreamNumberCounter] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
    620627                        $offset += 2;
     
    760767                    $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
    761768                    $offset += 2;
    762                     for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) {
     769                    for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < (int) $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) {
    763770                        // shortcut
    764771                        $thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter] = array();
     
    958965                    $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']     = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
    959966                    $offset += 2;
    960                     for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
     967                    for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < (int) $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
     968                        $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter] = array();
    961969                        $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
    962970                        $offset += 2;
     
    10071015            $ASFbitrateAudio = 0;
    10081016            $ASFbitrateVideo = 0;
    1009             for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
     1017            for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < (int) $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
    10101018                if (isset($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter])) {
    10111019                    switch ($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter]['type_raw']) {
     
    10311039            }
    10321040        }
    1033         if (isset($thisfile_asf['stream_properties_object']) && is_array($thisfile_asf['stream_properties_object'])) {
     1041        if (isset($thisfile_asf['stream_properties_object'])) {
    10341042
    10351043            $thisfile_audio['bitrate'] = 0;
     
    10681076
    10691077                        if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { // @phpstan-ignore-line
    1070                             foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
     1078                            foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { // @phpstan-ignore-line
    10711079                                if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
    10721080                                    $thisfile_asf_audiomedia_currentstream['bitrate'] = $dataarray['bitrate'];
     
    11541162
    11551163                        if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { // @phpstan-ignore-line
    1156                             foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
     1164                            foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { // @phpstan-ignore-line
    11571165                                if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
    11581166                                    $thisfile_asf_videomedia_currentstream['bitrate'] = $dataarray['bitrate'];
     
    12671275                    $offset += 4;
    12681276                    $thisfile_asf_simpleindexobject['index_entries_count']       = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
    1269                     $offset += 4;
    1270 
    1271                     $IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $thisfile_asf_simpleindexobject['index_entries_count']);
    1272                     for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; $IndexEntriesCounter++) {
     1277                    /** @var int|float|false $totalIndexEntriesCount */
     1278                    $totalIndexEntriesCount = $thisfile_asf_simpleindexobject['index_entries_count'];
     1279                    $offset += 4;
     1280
     1281                    $IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $totalIndexEntriesCount);
     1282                    for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $totalIndexEntriesCount; $IndexEntriesCounter++) {
     1283                        $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]                  = array();
    12731284                        $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
    12741285                        $offset += 4;
     
    13211332
    13221333                    $ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count']);
    1323                     for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
     1334                    for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
    13241335                        $IndexSpecifierStreamNumber = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
    13251336                        $offset += 2;
     1337                        $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]                    = array();
    13261338                        $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['stream_number']   = $IndexSpecifierStreamNumber;
    13271339                        $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type']      = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
     
    13321344                    $ASFIndexObjectData .= $this->fread(4);
    13331345                    $thisfile_asf_asfindexobject['index_entry_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
     1346                    /** @var int|float|false $totalIndexEntryCount */
     1347                    $totalIndexEntryCount = $thisfile_asf_asfindexobject['index_entry_count'];
    13341348                    $offset += 4;
    13351349
    13361350                    $ASFIndexObjectData .= $this->fread(8 * $thisfile_asf_asfindexobject['index_specifiers_count']);
    1337                     for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
     1351                    for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
    13381352                        $thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8));
    13391353                        $offset += 8;
     
    13411355
    13421356                    $ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']);
    1343                     for ($IndexEntryCounter = 0; $IndexEntryCounter < $thisfile_asf_asfindexobject['index_entry_count']; $IndexEntryCounter++) {
    1344                         for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
     1357                    for ($IndexEntryCounter = 0; $IndexEntryCounter < $totalIndexEntryCount; $IndexEntryCounter++) {
     1358                        for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
    13451359                            $thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
    13461360                            $offset += 4;
  • trunk/wp-includes/ID3/module.audio-video.quicktime.php

    r60136 r60565  
    4040
    4141    /**
     42     * real ugly, but so is the QuickTime structure that stores keys and values in different multi-nested locations that are hard to relate to each other
     43     * https://github.com/JamesHeinrich/getID3/issues/214
     44     *
     45     * @var int
     46     */
     47    private $metaDATAkey = 1;
     48
     49    /**
    4250     * @return bool
    4351     */
     
    4553        $info = &$this->getid3->info;
    4654
     55        $this->metaDATAkey = 1;
    4756        $info['fileformat'] = 'quicktime';
    4857        $info['quicktime']['hinting']    = false;
     
    148157
    149158                    if (strlen($lat_deg) == 2) {        // [+-]DD.D
    150                         $ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim($lat_deg, '0').$lat_deg_dec);
     159                        $ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * (float) (ltrim($lat_deg, '0').$lat_deg_dec);
    151160                    } elseif (strlen($lat_deg) == 4) {  // [+-]DDMM.M
    152                         $ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lat_deg, 0, 2), '0')) + floatval(ltrim(substr($lat_deg, 2, 2), '0').$lat_deg_dec / 60);
     161                        $ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * (int) ltrim(substr($lat_deg, 0, 2), '0') + ((float) (ltrim(substr($lat_deg, 2, 2), '0').$lat_deg_dec) / 60);
    153162                    } elseif (strlen($lat_deg) == 6) {  // [+-]DDMMSS.S
    154                         $ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lat_deg, 0, 2), '0')) + floatval((int) ltrim(substr($lat_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lat_deg, 4, 2), '0').$lat_deg_dec / 3600);
     163                        $ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * (int) ltrim(substr($lat_deg, 0, 2), '0') + ((int) ltrim(substr($lat_deg, 2, 2), '0') / 60) + ((float) (ltrim(substr($lat_deg, 4, 2), '0').$lat_deg_dec) / 3600);
    155164                    }
    156165
    157166                    if (strlen($lon_deg) == 3) {        // [+-]DDD.D
    158                         $ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * floatval(ltrim($lon_deg, '0').$lon_deg_dec);
     167                        $ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * (float) (ltrim($lon_deg, '0').$lon_deg_dec);
    159168                    } elseif (strlen($lon_deg) == 5) {  // [+-]DDDMM.M
    160                         $ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lon_deg, 0, 2), '0')) + floatval(ltrim(substr($lon_deg, 2, 2), '0').$lon_deg_dec / 60);
     169                        $ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * (int) ltrim(substr($lon_deg, 0, 2), '0') + ((float) (ltrim(substr($lon_deg, 2, 2), '0').$lon_deg_dec) / 60);
    161170                    } elseif (strlen($lon_deg) == 7) {  // [+-]DDDMMSS.S
    162                         $ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lon_deg, 0, 2), '0')) + floatval((int) ltrim(substr($lon_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lon_deg, 4, 2), '0').$lon_deg_dec / 3600);
     171                        $ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * (int) ltrim(substr($lon_deg, 0, 2), '0') + ((int) ltrim(substr($lon_deg, 2, 2), '0') / 60) + ((float) (ltrim(substr($lon_deg, 4, 2), '0').$lon_deg_dec) / 3600);
    163172                    }
    164173
    165174                    if (strlen($alt_deg) == 3) {        // [+-]DDD.D
    166                         $ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * floatval(ltrim($alt_deg, '0').$alt_deg_dec);
     175                        $ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * (float) (ltrim($alt_deg, '0').$alt_deg_dec);
    167176                    } elseif (strlen($alt_deg) == 5) {  // [+-]DDDMM.M
    168                         $ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * floatval(ltrim(substr($alt_deg, 0, 2), '0')) + floatval(ltrim(substr($alt_deg, 2, 2), '0').$alt_deg_dec / 60);
     177                        $ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * (int) ltrim(substr($alt_deg, 0, 2), '0') + ((float) (ltrim(substr($alt_deg, 2, 2), '0').$alt_deg_dec) / 60);
    169178                    } elseif (strlen($alt_deg) == 7) {  // [+-]DDDMMSS.S
    170                         $ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * floatval(ltrim(substr($alt_deg, 0, 2), '0')) + floatval((int) ltrim(substr($alt_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($alt_deg, 4, 2), '0').$alt_deg_dec / 3600);
     179                        $ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * (int) ltrim(substr($alt_deg, 0, 2), '0') + ((int) ltrim(substr($alt_deg, 2, 2), '0') / 60) + ((float) (ltrim(substr($alt_deg, 4, 2), '0').$alt_deg_dec) / 3600);
    171180                    }
    172181
     
    214223            } else {
    215224                $info['mime_type']  = 'video/mp4';
     225            }
     226        }
     227        if (!empty($info['quicktime']['ftyp']['signature']) && in_array($info['quicktime']['ftyp']['signature'], array('heic','heix','hevc','hevx','heim','heis','hevm','hevs'))) {
     228            if ($info['mime_type'] == 'video/quicktime') { // default value, as we
     229                // https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format
     230$this->error('HEIF files not currently supported');
     231                switch ($info['quicktime']['ftyp']['signature']) {
     232                    // https://github.com/strukturag/libheif/issues/83 (comment by Dirk Farin 2018-09-14)
     233                    case 'heic': // the usual HEIF images
     234                    case 'heix': // 10bit images, or anything that uses h265 with range extension
     235                    case 'hevc': // brands for image sequences
     236                    case 'hevx': // brands for image sequences
     237                    case 'heim': // multiview
     238                    case 'heis': // scalable
     239                    case 'hevm': // multiview sequence
     240                    case 'hevs': // scalable sequence
     241                        $info['fileformat'] = 'heif';
     242                        $info['mime_type'] = 'image/heif';
     243                        break;
     244                }
    216245            }
    217246        }
     
    794823
    795824                    $stsdEntriesDataOffset = 8;
    796                     for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
     825                    for ($i = 0; $i < (int) $atom_structure['number_entries']; $i++) {
    797826                        $atom_structure['sample_description_table'][$i]['size']             = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 4));
    798827                        $stsdEntriesDataOffset += 4;
     
    830859                                // video tracks
    831860                                // http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
    832                                 $atom_structure['sample_description_table'][$i]['temporal_quality'] =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'],  8,  4));
    833                                 $atom_structure['sample_description_table'][$i]['spatial_quality']  =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12,  4));
    834                                 $atom_structure['sample_description_table'][$i]['width']            =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16,  2));
    835                                 $atom_structure['sample_description_table'][$i]['height']           =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18,  2));
    836                                 $atom_structure['sample_description_table'][$i]['resolution_x']     = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24,  4));
    837                                 $atom_structure['sample_description_table'][$i]['resolution_y']     = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 28,  4));
    838                                 $atom_structure['sample_description_table'][$i]['data_size']        =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32,  4));
    839                                 $atom_structure['sample_description_table'][$i]['frame_count']      =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 36,  2));
    840                                 $atom_structure['sample_description_table'][$i]['compressor_name']  =                             substr($atom_structure['sample_description_table'][$i]['data'], 38,  4);
    841                                 $atom_structure['sample_description_table'][$i]['pixel_depth']      =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 42,  2));
    842                                 $atom_structure['sample_description_table'][$i]['color_table_id']   =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 44,  2));
     861                                // https://developer.apple.com/documentation/quicktime-file-format
     862                                $STSDvOffset = 8;
     863                                $atom_structure['sample_description_table'][$i]['temporal_quality'] =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset,  4)); $STSDvOffset +=  4;
     864                                $atom_structure['sample_description_table'][$i]['spatial_quality']  =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset,  4)); $STSDvOffset +=  4;
     865                                $atom_structure['sample_description_table'][$i]['width']            =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset,  2)); $STSDvOffset +=  2;
     866                                $atom_structure['sample_description_table'][$i]['height']           =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset,  2)); $STSDvOffset +=  2;
     867                                $atom_structure['sample_description_table'][$i]['resolution_x']     = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset,  4)); $STSDvOffset +=  4;
     868                                $atom_structure['sample_description_table'][$i]['resolution_y']     = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset,  4)); $STSDvOffset +=  4;
     869                                $atom_structure['sample_description_table'][$i]['data_size']        =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset,  4)); $STSDvOffset +=  4;
     870                                $atom_structure['sample_description_table'][$i]['frame_count']      =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset,  2)); $STSDvOffset +=  2;
     871                                $atom_structure['sample_description_table'][$i]['compressor_name']  =                             substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset, 32) ; $STSDvOffset += 32;
     872                                $atom_structure['sample_description_table'][$i]['compressor_name'] = $this->MaybePascal2String(rtrim($atom_structure['sample_description_table'][$i]['compressor_name'], "\x00")); // https://github.com/JamesHeinrich/getID3/issues/452
     873                                $atom_structure['sample_description_table'][$i]['pixel_depth']      =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset,  2)); $STSDvOffset +=  2;
     874                                $atom_structure['sample_description_table'][$i]['color_table_id']   =   getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], $STSDvOffset,  2)); $STSDvOffset +=  2;
    843875
    844876                                switch ($atom_structure['sample_description_table'][$i]['data_format']) {
     
    16421674                        $info['quicktime']['comments']['gps_latitude'][]  = floatval($latitude);
    16431675                        $info['quicktime']['comments']['gps_longitude'][] = floatval($longitude);
    1644                         if (!empty($altitude)) {
     1676                        if (!empty($altitude)) { // @phpstan-ignore-line
    16451677                            $info['quicktime']['comments']['gps_altitude'][] = floatval($altitude);
    16461678                        }
     
    17221754
    17231755                case 'data': // metaDATA atom
    1724                     static $metaDATAkey = 1; // real ugly, but so is the QuickTime structure that stores keys and values in different multinested locations that are hard to relate to each other
    17251756                    // seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in sample I have), remainder is useful data
    17261757                    $atom_structure['language'] =                           substr($atom_data, 4 + 0, 2);
    17271758                    $atom_structure['unknown']  = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2));
    17281759                    $atom_structure['data']     =                           substr($atom_data, 4 + 4);
    1729                     $atom_structure['key_name'] = (isset($info['quicktime']['temp_meta_key_names'][$metaDATAkey]) ? $info['quicktime']['temp_meta_key_names'][$metaDATAkey] : '');
    1730                     $metaDATAkey++;
     1760                    $atom_structure['key_name'] = (isset($info['quicktime']['temp_meta_key_names'][$this->metaDATAkey]) ? $info['quicktime']['temp_meta_key_names'][$this->metaDATAkey] : '');
     1761                    $this->metaDATAkey++;
     1762
     1763                    switch ($atom_structure['key_name']) {
     1764                        case 'com.android.capture.fps':
     1765                            $atom_structure['data'] = getid3_lib::BigEndian2Float($atom_structure['data']);
     1766                            break;
     1767                    }
    17311768
    17321769                    if ($atom_structure['key_name'] && $atom_structure['data']) {
    1733                         @$info['quicktime']['comments'][str_replace('com.apple.quicktime.', '', $atom_structure['key_name'])][] = $atom_structure['data'];
     1770                        @$info['quicktime']['comments'][str_replace('com.android.', '', str_replace('com.apple.quicktime.', '', $atom_structure['key_name']))][] = $atom_structure['data'];
    17341771                    }
    17351772                    break;
     
    19722009                                        preg_match('#^([0-9]{1,3})([0-9]{2}\\.[0-9]+)$#', $GPS_this_GPRMC['raw'][$latlon], $matches);
    19732010                                        list($dummy, $deg, $min) = $matches;
    1974                                         $GPS_this_GPRMC[$latlon] = $deg + ($min / 60);
     2011                                        $GPS_this_GPRMC[$latlon] = (int) $deg + ((float) $min / 60);
    19752012                                    }
    19762013                                    $GPS_this_GPRMC['latitude']  *= (($GPS_this_GPRMC['raw']['latitude_direction']  == 'S') ? -1 : 1);
     
    19792016                                    $GPS_this_GPRMC['heading']    = $GPS_this_GPRMC['raw']['angle'];
    19802017                                    $GPS_this_GPRMC['speed_knot'] = $GPS_this_GPRMC['raw']['knots'];
    1981                                     $GPS_this_GPRMC['speed_kmh']  = $GPS_this_GPRMC['raw']['knots'] * 1.852;
     2018                                    $GPS_this_GPRMC['speed_kmh']  = (float) $GPS_this_GPRMC['raw']['knots'] * 1.852;
    19822019                                    if ($GPS_this_GPRMC['raw']['variation']) {
    1983                                         $GPS_this_GPRMC['variation']  = $GPS_this_GPRMC['raw']['variation'];
     2020                                        $GPS_this_GPRMC['variation']  = (float) $GPS_this_GPRMC['raw']['variation'];
    19842021                                        $GPS_this_GPRMC['variation'] *= (($GPS_this_GPRMC['raw']['variation_direction'] == 'W') ? -1 : 1);
    19852022                                    }
     
    21152152                    $esds_offset += 1;
    21162153                    if ($atom_structure['ES_DescrTag'] != 0x03) {
    2117                         $this->warning('expecting esds.ES_DescrTag = 0x03, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DescrTag']).'), at offset '.$atom_structure['offset']);
     2154                        $this->warning('expecting esds.ES_DescrTag = 0x03, found 0x'.sprintf('%02X', $atom_structure['ES_DescrTag']).', at offset '.$atom_structure['offset']);
    21182155                        break;
    21192156                    }
     
    21442181                    $esds_offset += 1;
    21452182                    if ($atom_structure['ES_DecoderConfigDescrTag'] != 0x04) {
    2146                         $this->warning('expecting esds.ES_DecoderConfigDescrTag = 0x04, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DecoderConfigDescrTag']).'), at offset '.$atom_structure['offset']);
     2183                        $this->warning('expecting esds.ES_DecoderConfigDescrTag = 0x04, found 0x'.sprintf('%02X', $atom_structure['ES_DecoderConfigDescrTag']).', at offset '.$atom_structure['offset']);
    21472184                        break;
    21482185                    }
     
    21752212                    $esds_offset += 1;
    21762213                    if ($atom_structure['ES_DecSpecificInfoTag'] != 0x05) {
    2177                         $this->warning('expecting esds.ES_DecSpecificInfoTag = 0x05, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DecSpecificInfoTag']).'), at offset '.$atom_structure['offset']);
     2214                        $this->warning('expecting esds.ES_DecSpecificInfoTag = 0x05, found 0x'.sprintf('%02X', $atom_structure['ES_DecSpecificInfoTag']).', at offset '.$atom_structure['offset']);
    21782215                        break;
    21792216                    }
     
    21862223                    $esds_offset += 1;
    21872224                    if ($atom_structure['ES_SLConfigDescrTag'] != 0x06) {
    2188                         $this->warning('expecting esds.ES_SLConfigDescrTag = 0x05, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_SLConfigDescrTag']).'), at offset '.$atom_structure['offset']);
     2225                        $this->warning('expecting esds.ES_SLConfigDescrTag = 0x05, found 0x'.sprintf('%02X', $atom_structure['ES_SLConfigDescrTag']).', at offset '.$atom_structure['offset']);
    21892226                        break;
    21902227                    }
  • trunk/wp-includes/ID3/module.audio-video.riff.php

    r56486 r60565  
    6868        $RIFFsubtype = substr($RIFFheader, 8, 4);
    6969
     70        if ($RIFFsize == "\x00\x00\x00\x00") {
     71            // https://github.com/JamesHeinrich/getID3/issues/468
     72            // may occur in streaming files where the data size is unknown
     73            $thisfile_riff['header_size'] = $info['avdataend'] - 8;
     74            $this->warning('RIFF size field is empty, assuming the correct value is filesize-8 ('.$thisfile_riff['header_size'].')');
     75        } else {
     76            $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);
     77        }
     78
    7079        switch ($RIFFtype) {
    71 
    7280            case 'FORM':  // AIFF, AIFC
    7381                //$info['fileformat']   = 'aiff';
    7482                $this->container = 'aiff';
    75                 $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);
    7683                $thisfile_riff[$RIFFsubtype]  = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4));
    7784                break;
     
    8289                //$info['fileformat']   = 'riff';
    8390                $this->container = 'riff';
    84                 $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);
    8591                if ($RIFFsubtype == 'RMP3') {
    8692                    // RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s
     
    99105                }
    100106
    101                 $nextRIFFoffset = $Original['avdataoffset'] + 8 + $thisfile_riff['header_size']; // 8 = "RIFF" + 32-bit offset
     107                $nextRIFFoffset = (int) $Original['avdataoffset'] + 8 + (int) $thisfile_riff['header_size']; // 8 = "RIFF" + 32-bit offset
    102108                while ($nextRIFFoffset < min($info['filesize'], $info['avdataend'])) {
    103109                    try {
     
    306312                        // Keep only string as far as first null byte, discard rest of fixed-width data
    307313                        // https://github.com/JamesHeinrich/getID3/issues/263
    308                         $null_terminator_offset = strpos($thisfile_riff_WAVE_bext_0[$bext_key], "\x00");
    309                         $thisfile_riff_WAVE_bext_0[$bext_key] = substr($thisfile_riff_WAVE_bext_0[$bext_key], 0, $null_terminator_offset);
     314                        // https://github.com/JamesHeinrich/getID3/issues/430
     315                        $null_terminator_rows = explode("\x00", $thisfile_riff_WAVE_bext_0[$bext_key]);
     316                        $thisfile_riff_WAVE_bext_0[$bext_key] = $null_terminator_rows[0];
    310317                    }
    311318
     
    473480                                if (substr($value, 0, 3) == '[{"') {
    474481                                    if ($decoded = @json_decode($value, true)) {
    475                                         if (!empty($decoded) && (count($decoded) == 1)) {
     482                                        if (count($decoded) === 1) {
    476483                                            $value = $decoded[0];
    477484                                        } else {
     
    11331140                foreach ($CommentsChunkNames as $key => $value) {
    11341141                    if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) {
    1135                         $thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];
     1142                        // https://github.com/JamesHeinrich/getID3/issues/430
     1143                        $null_terminator_rows = explode("\x00", $thisfile_riff[$RIFFsubtype][$key][0]['data']);
     1144                        $thisfile_riff['comments'][$value][] = $null_terminator_rows[0];
    11361145                    }
    11371146                }
     
    12251234                foreach ($CommentsChunkNames as $key => $value) {
    12261235                    if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) {
    1227                         $thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];
     1236                        // https://github.com/JamesHeinrich/getID3/issues/430
     1237                        $null_terminator_rows = explode("\x00", $thisfile_riff[$RIFFsubtype][$key][0]['data']);
     1238                        $thisfile_riff['comments'][$value][] = $null_terminator_rows[0];
    12281239                    }
    12291240                }
     
    13651376
    13661377        if ($info['playtime_seconds'] > 0) {
    1367             if (isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {
     1378            if ($thisfile_riff_audio !== null && $thisfile_riff_video !== null) {
    13681379
    13691380                if (!isset($info['bitrate'])) {
     
    13711382                }
    13721383
    1373             } elseif (isset($thisfile_riff_audio) && !isset($thisfile_riff_video)) {
     1384            } elseif ($thisfile_riff_audio !== null && $thisfile_riff_video === null) { // @phpstan-ignore-line
    13741385
    13751386                if (!isset($thisfile_audio['bitrate'])) {
     
    13771388                }
    13781389
    1379             } elseif (!isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {
     1390            } elseif ($thisfile_riff_audio === null && $thisfile_riff_video !== null) {
    13801391
    13811392                if (!isset($thisfile_video['bitrate'])) {
     
    16021613                    break;
    16031614                }
    1604                 if (($chunksize == 0) && ($chunkname != 'JUNK')) {
    1605                     $this->warning('Chunk ('.$chunkname.') size at offset '.($this->ftell() - 4).' is zero. Aborting RIFF parsing.');
    1606                     break;
     1615                if ($chunksize == 0) {
     1616                    if ($chunkname == 'JUNK') {
     1617                        // this is allowed
     1618                    } elseif ($chunkname == 'data') {
     1619                        // https://github.com/JamesHeinrich/getID3/issues/468
     1620                        // may occur in streaming files where the data size is unknown
     1621                        $chunksize = $info['avdataend'] - $this->ftell();
     1622                        $this->warning('RIFF.data size field is empty, assuming the correct value is filesize-offset ('.$chunksize.')');
     1623                    } else {
     1624                        $this->warning('Chunk ('.$chunkname.') size at offset '.($this->ftell() - 4).' is zero. Aborting RIFF parsing.');
     1625                        break;
     1626                    }
    16071627                }
    16081628                if (($chunksize % 2) != 0) {
     
    16941714                        }
    16951715                        $thisindex = 0;
    1696                         if (isset($RIFFchunk[$chunkname]) && is_array($RIFFchunk[$chunkname])) {
     1716                        if (isset($RIFFchunk[$chunkname])) {
    16971717                            $thisindex = count($RIFFchunk[$chunkname]);
    16981718                        }
  • trunk/wp-includes/ID3/module.audio.mp3.php

    r56486 r60565  
    306306
    307307            if ($info['audio']['bitrate_mode'] == 'cbr') {
    308                 $encoder_options = strtoupper($info['audio']['bitrate_mode']).round($info['audio']['bitrate'] / 1000);
     308                if ($info['audio']['bitrate'] == 'free') {
     309                    $encoder_options = strtoupper($info['audio']['bitrate_mode']);
     310                } else {
     311                    $encoder_options = strtoupper($info['audio']['bitrate_mode']).round($info['audio']['bitrate'] / 1000);
     312                }
    309313            } else {
    310314                $encoder_options = strtoupper($info['audio']['bitrate_mode']);
     
    316320        }
    317321
    318         if (isset($thisfile_mpeg_audio['bitrate']) && $thisfile_mpeg_audio['bitrate'] === 'free') {
     322        if (isset($thisfile_mpeg_audio['bitrate']) && ($thisfile_mpeg_audio['bitrate'] === 'free')) {
    319323            $encoder_options .= ' --freeformat';
    320324        }
     
    713717                        $info['audio']['bitrate'] = $framelengthfloat * $thisfile_mpeg_audio['sample_rate'] * (2 / $info['audio']['channels']) / 144;
    714718                    }
    715                     $thisfile_mpeg_audio['framelength'] = floor($framelengthfloat);
     719                    $thisfile_mpeg_audio['framelength'] = (int) floor($framelengthfloat);
    716720                }
    717721
     
    920924
    921925                            // LAME CBR
    922                             if ($thisfile_mpeg_audio_lame_raw['vbr_method'] == 1 && $thisfile_mpeg_audio['bitrate'] !== 'free') {
     926                            if (($thisfile_mpeg_audio_lame_raw['vbr_method'] == 1) && ($thisfile_mpeg_audio['bitrate'] !== 'free')) {
    923927
    924928                                $thisfile_mpeg_audio['bitrate_mode'] = 'cbr';
     
    11751179            $nextframetestarray = array('error' => array(), 'warning' => array(), 'avdataend' => $info['avdataend'], 'avdataoffset'=>$info['avdataoffset']);
    11761180            if ($this->decodeMPEGaudioHeader($nextframetestoffset, $nextframetestarray, false)) {
    1177                 /** @phpstan-ignore-next-line */
    11781181                getid3_lib::safe_inc($info['mp3_validity_check_bitrates'][$nextframetestarray['mpeg']['audio']['bitrate']]);
    11791182                if ($ScanAsCBR) {
     
    11871190                // next frame is OK, get ready to check the one after that
    11881191                if (isset($nextframetestarray['mpeg']['audio']['framelength']) && ($nextframetestarray['mpeg']['audio']['framelength'] > 0)) {
    1189                     $nextframetestoffset += $nextframetestarray['mpeg']['audio']['framelength'];
     1192                    $nextframetestoffset += (int) $nextframetestarray['mpeg']['audio']['framelength'];
    11901193                } else {
    11911194                    $this->error('Frame at offset ('.$offset.') is has an invalid frame length.');
     
    17621765        if (empty($MPEGaudioBitrate)) {
    17631766            $MPEGaudioBitrate = array (
    1764                 '1'  =>  array (1 => array('free', 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000),
    1765                                 2 => array('free', 32000, 48000, 56000,  64000,  80000,  96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000),
    1766                                 3 => array('free', 32000, 40000, 48000,  56000,  64000,  80000,  96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000)
    1767                                ),
    1768 
    1769                 '2'  =>  array (1 => array('free', 32000, 48000, 56000,  64000,  80000,  96000, 112000, 128000, 144000, 160000, 176000, 192000, 224000, 256000),
    1770                                 2 => array('free',  8000, 16000, 24000,  32000,  40000,  48000,  56000,  64000,  80000,  96000, 112000, 128000, 144000, 160000),
    1771                                )
     1767                '1' => array(
     1768                    1 => array('free', 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000),
     1769                    2 => array('free', 32000, 48000, 56000,  64000,  80000,  96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000),
     1770                    3 => array('free', 32000, 40000, 48000,  56000,  64000,  80000,  96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000)
     1771                ),
     1772                '2' => array(
     1773                    1 => array('free', 32000, 48000, 56000,  64000,  80000,  96000, 112000, 128000, 144000, 160000, 176000, 192000, 224000, 256000),
     1774                    2 => array('free',  8000, 16000, 24000,  32000,  40000,  48000,  56000,  64000,  80000,  96000, 112000, 128000, 144000, 160000),
     1775                ),
    17721776            );
    17731777            $MPEGaudioBitrate['2'][3] = $MPEGaudioBitrate['2'][2];
  • trunk/wp-includes/ID3/module.audio.ogg.php

    r60148 r60565  
    351351            $LastChunkOfOgg = strrev($this->fread($this->getid3->fread_buffer_size()));
    352352            if ($LastOggSpostion = strpos($LastChunkOfOgg, 'SggO')) {
     353                if (substr($LastChunkOfOgg, 13, 8) === "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF") {
     354                    // https://github.com/JamesHeinrich/getID3/issues/450
     355                    // "Sometimes, Opus encoders (WhatsApp voice registrations and others) add a special last header with a granule duration of 0xFFFFFFFFFFFFFF.
     356                    // This value indicates "this is the end," but must be ignored; otherwise, it makes calculations wrong."
     357                    $LastOggSpostion = strpos($LastChunkOfOgg, 'SggO', $LastOggSpostion + 1);
     358                }
    353359                $this->fseek($info['avdataend'] - ($LastOggSpostion + strlen('SggO')));
    354360                $info['avdataend'] = $this->ftell();
  • trunk/wp-includes/ID3/module.tag.apetag.php

    r56486 r60565  
    4242            $this->warning('Unable to check for APEtags because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB');
    4343            return false;
     44        }
     45        if (PHP_INT_MAX == 2147483647) {
     46            // https://github.com/JamesHeinrich/getID3/issues/439
     47            $this->warning('APEtag flags may not be parsed correctly on 32-bit PHP');
    4448        }
    4549
  • trunk/wp-includes/ID3/module.tag.id3v2.php

    r56486 r60565  
    660660            // Identifier              <up to 64 bytes binary data>
    661661            $exploded = explode("\x00", $parsedFrame['data'], 2);
    662             $parsedFrame['ownerid'] = (isset($exploded[0]) ? $exploded[0] : '');
     662            $parsedFrame['ownerid'] = $exploded[0];
    663663            $parsedFrame['data']    = (isset($exploded[1]) ? $exploded[1] : '');
    664664
     
    10691069
    10701070                    $frame_remainingdata = substr($frame_remainingdata, $frame_terminatorpos + strlen($frame_textencoding_terminator));
    1071                     if (($timestampindex == 0) && (ord($frame_remainingdata[0]) != 0)) {
    1072                         // timestamp probably omitted for first data item
    1073                     } else {
    1074                         $parsedFrame['lyrics'][$timestampindex]['timestamp'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, 0, 4));
    1075                         $frame_remainingdata = substr($frame_remainingdata, 4);
     1071                    if (strlen($frame_remainingdata)) { // https://github.com/JamesHeinrich/getID3/issues/444
     1072                        if (($timestampindex == 0) && (ord($frame_remainingdata[0]) != 0)) {
     1073                            // timestamp probably omitted for first data item
     1074                        } else {
     1075                            $parsedFrame['lyrics'][$timestampindex]['timestamp'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, 0, 4));
     1076                            $frame_remainingdata = substr($frame_remainingdata, 4);
     1077                        }
     1078                        $timestampindex++;
    10761079                    }
    1077                     $timestampindex++;
    10781080                }
    10791081            }
     
    13051307
    13061308            $frame_offset = 0;
    1307             $parsedFrame['adjustmentbits'] = substr($parsedFrame['data'], $frame_offset++, 1);
     1309            $parsedFrame['adjustmentbits'] = ord(substr($parsedFrame['data'], $frame_offset++, 1));
    13081310            $frame_adjustmentbytes = ceil($parsedFrame['adjustmentbits'] / 8);
    13091311
  • trunk/wp-includes/ID3/module.tag.lyrics3.php

    r51846 r60565  
    111111                if (isset($info['lyrics3']['tag_offset_start'])) {
    112112                    $GETID3_ERRORARRAY = &$info['warning'];
    113                     getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true);
    114                     $getid3_temp = new getID3();
    115                     $getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize'], $this->getid3->fp);
    116                     $getid3_apetag = new getid3_apetag($getid3_temp);
    117                     $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start'];
    118                     $getid3_apetag->Analyze();
    119                     if (!empty($getid3_temp->info['ape'])) {
    120                         $info['ape'] = $getid3_temp->info['ape'];
    121                     }
    122                     if (!empty($getid3_temp->info['replay_gain'])) {
    123                         $info['replay_gain'] = $getid3_temp->info['replay_gain'];
    124                     }
    125                     unset($getid3_temp, $getid3_apetag);
     113                    if ($this->getid3->option_tag_apetag) {
     114                        getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true);
     115                        $getid3_temp = new getID3();
     116                        $getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize'], $this->getid3->fp);
     117                        $getid3_apetag = new getid3_apetag($getid3_temp);
     118                        $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start'];
     119                        $getid3_apetag->Analyze();
     120                        if (!empty($getid3_temp->info['ape'])) {
     121                            $info['ape'] = $getid3_temp->info['ape'];
     122                        }
     123                        if (!empty($getid3_temp->info['replay_gain'])) {
     124                            $info['replay_gain'] = $getid3_temp->info['replay_gain'];
     125                        }
     126                        unset($getid3_temp, $getid3_apetag);
     127                    } else {
     128                        $this->warning('Unable to check for Lyrics3 and APE tags interaction since option_tag_apetag=FALSE');
     129                    }
    126130                } else {
    127131                    $this->warning('Lyrics3 and APE tags appear to have become entangled (most likely due to updating the APE tags with a non-Lyrics3-aware tagger)');
     
    228232                            if (strpos($imagestring, '||') !== false) {
    229233                                $imagearray = explode('||', $imagestring);
    230                                 $ParsedLyrics3['images'][$key]['filename']     =                                (isset($imagearray[0]) ? $imagearray[0] : '');
     234                                $ParsedLyrics3['images'][$key]['filename']     =                                $imagearray[0];
    231235                                $ParsedLyrics3['images'][$key]['description']  =                                (isset($imagearray[1]) ? $imagearray[1] : '');
    232236                                $ParsedLyrics3['images'][$key]['timestamp']    = $this->Lyrics3Timestamp2Seconds(isset($imagearray[2]) ? $imagearray[2] : '');
     
    273277    public function Lyrics3Timestamp2Seconds($rawtimestamp) {
    274278        if (preg_match('#^\\[([0-9]{2}):([0-9]{2})\\]$#', $rawtimestamp, $regs)) {
    275             return (int) (($regs[1] * 60) + $regs[2]);
     279            return (int) (((int) $regs[1] * 60) + (int) $regs[2]);
    276280        }
    277281        return false;
     
    288292        foreach ($lyricsarray as $key => $lyricline) {
    289293            $regs = array();
    290             unset($thislinetimestamps);
     294            $thislinetimestamps = array();
    291295            while (preg_match('#^(\\[[0-9]{2}:[0-9]{2}\\])#', $lyricline, $regs)) {
    292296                $thislinetimestamps[] = $this->Lyrics3Timestamp2Seconds($regs[0]);
     
    294298            }
    295299            $notimestamplyricsarray[$key] = $lyricline;
    296             if (isset($thislinetimestamps) && is_array($thislinetimestamps)) {
     300            if (count($thislinetimestamps) > 0) {
    297301                sort($thislinetimestamps);
    298302                foreach ($thislinetimestamps as $timestampkey => $timestamp) {
    299                     if (isset($Lyrics3data['synchedlyrics'][$timestamp])) {
     303                    if (isset($Lyrics3data['comments']['synchedlyrics'][$timestamp])) {
    300304                        // timestamps only have a 1-second resolution, it's possible that multiple lines
    301305                        // could have the same timestamp, if so, append
    302                         $Lyrics3data['synchedlyrics'][$timestamp] .= "\r\n".$lyricline;
     306                        $Lyrics3data['comments']['synchedlyrics'][$timestamp] .= "\r\n".$lyricline;
    303307                    } else {
    304                         $Lyrics3data['synchedlyrics'][$timestamp] = $lyricline;
    305                     }
    306                 }
    307             }
    308         }
    309         $Lyrics3data['unsynchedlyrics'] = implode("\r\n", $notimestamplyricsarray);
    310         if (isset($Lyrics3data['synchedlyrics']) && is_array($Lyrics3data['synchedlyrics'])) {
    311             ksort($Lyrics3data['synchedlyrics']);
     308                        $Lyrics3data['comments']['synchedlyrics'][$timestamp] = $lyricline;
     309                    }
     310                }
     311            }
     312        }
     313        $Lyrics3data['comments']['unsynchedlyrics'][0] = implode("\r\n", $notimestamplyricsarray);
     314        if (isset($Lyrics3data['comments']['synchedlyrics']) && is_array($Lyrics3data['comments']['synchedlyrics'])) {
     315            ksort($Lyrics3data['comments']['synchedlyrics']);
    312316        }
    313317        return true;
  • trunk/wp-includes/version.php

    r60562 r60565  
    1717 * @global string $wp_version
    1818 */
    19 $wp_version = '7.0-alpha-61250';
     19$wp_version = '7.0-alpha-61253';
    2020
    2121/**
Note: See TracChangeset for help on using the changeset viewer.