Make WordPress Core

Changeset 56975


Ignore:
Timestamp:
10/20/2023 01:27:56 PM (16 months ago)
Author:
SergeyBiryukov
Message:

External Libraries: Update getID3 to version 1.9.23.

The latest version includes numerous bug fixes, a few new features, as well as various improvements for PHP 8.1 and PHP 8.2 support.

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

References:

Follow-up to [47601], [48278], [52254], [54376].

Props jrf.
Fixes #59683.

Location:
trunk/src/wp-includes/ID3
Files:
1 deleted
13 edited

Legend:

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

    r54376 r56975  
    122122        }
    123123        // if integers are 64-bit - no other check required
    124         if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) { // phpcs:ignore PHPCompatibility.Constants.NewConstants.php_int_minFound
     124        if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) {
    125125            return true;
    126126        }
    127127        return false;
     128    }
     129
     130    /**
     131     * Perform a division, guarding against division by zero
     132     *
     133     * @param float|int $numerator
     134     * @param float|int $denominator
     135     * @param float|int $fallback
     136     * @return float|int
     137     */
     138    public static function SafeDiv($numerator, $denominator, $fallback = 0) {
     139        return $denominator ? $numerator / $denominator : $fallback;
    128140    }
    129141
     
    135147    public static function DecimalizeFraction($fraction) {
    136148        list($numerator, $denominator) = explode('/', $fraction);
    137         return $numerator / ($denominator ? $denominator : 1);
     149        return (int) $numerator / ($denominator ? $denominator : 1);
    138150    }
    139151
     
    872884     */
    873885    public static function iconv_fallback_iso88591_utf8($string, $bom=false) {
    874         if (function_exists('utf8_encode')) {
    875             return utf8_encode($string);
    876         }
    877         // utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
    878886        $newcharstring = '';
    879887        if ($bom) {
     
    944952     */
    945953    public static function iconv_fallback_utf8_iso88591($string) {
    946         if (function_exists('utf8_decode')) {
    947             return utf8_decode($string);
    948         }
    949         // utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
    950954        $newcharstring = '';
    951955        $offset = 0;
  • trunk/src/wp-includes/ID3/getid3.php

    r54376 r56975  
    388388    protected $startup_warning = '';
    389389
    390     const VERSION           = '1.9.22-202207161647';
     390    const VERSION           = '1.9.23-202310190849';
    391391    const FREAD_BUFFER_SIZE = 32768;
    392392
     
    439439        }
    440440
    441         // check for magic quotes in PHP < 7.4.0 (when these functions became deprecated)
    442         if (version_compare(PHP_VERSION, '7.4.0', '<')) {
     441        // check for magic quotes in PHP < 5.4.0 (when these options were removed and getters always return false)
     442        if (version_compare(PHP_VERSION, '5.4.0', '<')) {
    443443            // Check for magic_quotes_runtime
    444444            if (function_exists('get_magic_quotes_runtime')) {
    445445                // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_runtimeDeprecated
    446                 if (get_magic_quotes_runtime()) {
     446                if (get_magic_quotes_runtime()) { // @phpstan-ignore-line
    447447                    $this->startup_error .= 'magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).'."\n";
    448448                }
     
    451451            if (function_exists('get_magic_quotes_gpc')) {
    452452                // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_gpcDeprecated
    453                 if (get_magic_quotes_gpc()) {
     453                if (get_magic_quotes_gpc()) { // @phpstan-ignore-line
    454454                    $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";
    455455                }
     
    14651465                            'module'    => 'xz',
    14661466                            'mime_type' => 'application/x-xz',
     1467                            'fail_id3'  => 'ERROR',
     1468                            'fail_ape'  => 'ERROR',
     1469                        ),
     1470
     1471                // XZ   - data         - XZ compressed data
     1472                '7zip'  => array(
     1473                            'pattern'   => '^7z\\xBC\\xAF\\x27\\x1C',
     1474                            'group'     => 'archive',
     1475                            'module'    => '7zip',
     1476                            'mime_type' => 'application/x-7z-compressed',
    14671477                            'fail_id3'  => 'ERROR',
    14681478                            'fail_ape'  => 'ERROR',
     
    19831993        $BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;
    19841994
    1985         $this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
     1995        $this->info['video']['compression_ratio'] = getid3_lib::SafeDiv($BitrateCompressed, $BitrateUncompressed, 1);
    19861996        return true;
    19871997    }
     
    21892199
    21902200    /**
     2201     * @phpstan-impure
     2202     *
    21912203     * @return int|bool
    21922204     */
     
    22002212    /**
    22012213     * @param int $bytes
     2214     *
     2215     * @phpstan-impure
    22022216     *
    22032217     * @return string|false
     
    22462260     * @param int $whence
    22472261     *
     2262     * @phpstan-impure
     2263     *
    22482264     * @return int
    22492265     *
     
    22872303
    22882304    /**
     2305     * @phpstan-impure
     2306     *
    22892307     * @return string|false
    22902308     *
     
    23422360
    23432361    /**
     2362     * @phpstan-impure
     2363     *
    23442364     * @return bool
    23452365     */
  • trunk/src/wp-includes/ID3/license.txt

    r46587 r56975  
    2121Mozilla MPL: https://www.mozilla.org/MPL/2.0/                (v2)
    2222
    23 getID3 Commercial License: https://www.getid3.org/#gCL (payment required)
     23getID3 Commercial License: https://www.getid3.org/#gCL
     24(no longer available, existing licenses remain valid)
    2425
    2526*****************************************************************
  • trunk/src/wp-includes/ID3/module.audio-video.asf.php

    r54376 r56975  
    194194
    195195                        //$info['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate'];
    196                         $info['bitrate'] = ((isset($thisfile_asf_filepropertiesobject['filesize']) ? $thisfile_asf_filepropertiesobject['filesize'] : $info['filesize']) * 8) / $info['playtime_seconds'];
     196                        $info['bitrate'] = getid3_lib::SafeDiv($thisfile_asf_filepropertiesobject['filesize'] * 8, $info['playtime_seconds']);
    197197                    }
    198198                    break;
     
    10671067                        }
    10681068
    1069                         if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) {
     1069                        if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { // @phpstan-ignore-line
    10701070                            foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
    10711071                                if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
     
    11531153                        $thisfile_asf_videomedia_currentstream['format_data']['codec_data']       = substr($streamdata['type_specific_data'], $videomediaoffset);
    11541154
    1155                         if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) {
     1155                        if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { // @phpstan-ignore-line
    11561156                            foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
    11571157                                if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
  • trunk/src/wp-includes/ID3/module.audio-video.matroska.php

    r52254 r56975  
    293293                        $track_info['display_y']    = (isset($trackarray['DisplayHeight']) ? $trackarray['DisplayHeight'] : $trackarray['PixelHeight']);
    294294
    295                         if (isset($trackarray['PixelCropBottom'])) { $track_info['crop_bottom'] = $trackarray['PixelCropBottom']; }
    296                         if (isset($trackarray['PixelCropTop']))    { $track_info['crop_top']    = $trackarray['PixelCropTop']; }
    297                         if (isset($trackarray['PixelCropLeft']))   { $track_info['crop_left']   = $trackarray['PixelCropLeft']; }
    298                         if (isset($trackarray['PixelCropRight']))  { $track_info['crop_right']  = $trackarray['PixelCropRight']; }
    299                         if (isset($trackarray['DefaultDuration'])) { $track_info['frame_rate']  = round(1000000000 / $trackarray['DefaultDuration'], 3); }
    300                         if (isset($trackarray['CodecName']))       { $track_info['codec']       = $trackarray['CodecName']; }
     295                        if (isset($trackarray['PixelCropBottom']))  { $track_info['crop_bottom'] = $trackarray['PixelCropBottom']; }
     296                        if (isset($trackarray['PixelCropTop']))     { $track_info['crop_top']    = $trackarray['PixelCropTop']; }
     297                        if (isset($trackarray['PixelCropLeft']))    { $track_info['crop_left']   = $trackarray['PixelCropLeft']; }
     298                        if (isset($trackarray['PixelCropRight']))   { $track_info['crop_right']  = $trackarray['PixelCropRight']; }
     299                        if (!empty($trackarray['DefaultDuration'])) { $track_info['frame_rate']  = round(1000000000 / $trackarray['DefaultDuration'], 3); }
     300                        if (isset($trackarray['CodecName']))        { $track_info['codec']       = $trackarray['CodecName']; }
    301301
    302302                        switch ($trackarray['CodecID']) {
  • trunk/src/wp-includes/ID3/module.audio-video.quicktime.php

    r54376 r56975  
    153153                        $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);
    154154                    } elseif (strlen($lat_deg) == 6) {  // [+-]DDMMSS.S
    155                         $ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lat_deg, 0, 2), '0')) + floatval(ltrim(substr($lat_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lat_deg, 4, 2), '0').$lat_deg_dec / 3600);
     155                        $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);
    156156                    }
    157157
     
    161161                        $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);
    162162                    } elseif (strlen($lon_deg) == 7) {  // [+-]DDDMMSS.S
    163                         $ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lon_deg, 0, 2), '0')) + floatval(ltrim(substr($lon_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lon_deg, 4, 2), '0').$lon_deg_dec / 3600);
     163                        $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);
    164164                    }
    165165
     
    169169                        $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);
    170170                    } elseif (strlen($alt_deg) == 7) {  // [+-]DDDMMSS.S
    171                         $ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * floatval(ltrim(substr($alt_deg, 0, 2), '0')) + floatval(ltrim(substr($alt_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($alt_deg, 4, 2), '0').$alt_deg_dec / 3600);
     171                        $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);
    172172                    }
    173173
     
    333333                        } elseif (isset($value_array['time_to_sample_table'])) {
    334334                            foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) {
    335                                 if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0)) {
     335                                if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0) && !empty($info['quicktime']['time_scale'])) {
    336336                                    $framerate  = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3);
    337337                                    $framecount = $value_array2['sample_count'];
     
    777777
    778778                case 'stsd': // Sample Table Sample Description atom
    779                     $atom_structure['version']        = getid3_lib::BigEndian2Int(substr($atom_data,  0, 1));
    780                     $atom_structure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atom_data,  1, 3)); // hardcoded: 0x0000
     779                    $atom_structure['version']        = getid3_lib::BigEndian2Int(substr($atom_data,  0, 1)); // hardcoded: 0x00
     780                    $atom_structure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atom_data,  1, 3)); // hardcoded: 0x000000
    781781                    $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data,  4, 4));
    782782
     
    806806                        $atom_structure['sample_description_table'][$i]['data']             =                           substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));
    807807                        $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);
    808 
    809808                        if (substr($atom_structure['sample_description_table'][$i]['data'],  1, 54) == 'application/octet-stream;type=com.parrot.videometadata') {
    810809                            // special handling for apparently-malformed (TextMetaDataSampleEntry?) data for some version of Parrot drones
     
    894893
    895894                                    case 'mp4a':
    896                                     default:
     895                                        $atom_structure['sample_description_table'][$i]['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_structure['sample_description_table'][$i]['data'], 20), $baseoffset + $stsdEntriesDataOffset - 20 - 16, $atomHierarchy, $ParseAllPossibleAtoms);
     896
    897897                                        $info['quicktime']['audio']['codec']       = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
    898898                                        $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate'];
     
    919919                                                break;
    920920                                        }
     921                                        break;
     922
     923                                    default:
    921924                                        break;
    922925                                }
     
    16671670                        $atom_structure['data'] = $atom_data;
    16681671                        $atom_structure['image_mime'] = 'image/jpeg';
    1669                         $atom_structure['description'] = isset($descriptions[$atomname]) ? $descriptions[$atomname] : 'Nikon preview image';
     1672                        $atom_structure['description'] = $descriptions[$atomname];
    16701673                        $info['quicktime']['comments']['picture'][] = array(
    16711674                            'image_mime' => $atom_structure['image_mime'],
     
    16841687                    $makerNoteVersion = '';
    16851688                    for ($i = 0, $iMax = strlen($atom_data); $i < $iMax; ++$i) {
    1686                         if (ord($atom_data[$i]) >= 0x00 && ord($atom_data[$i]) <= 0x1F) {
     1689                        if (ord($atom_data[$i]) <= 0x1F) {
    16871690                            $makerNoteVersion .= ' '.ord($atom_data[$i]);
    16881691                        } else {
     
    21012104                    break;
    21022105
     2106
     2107                case 'esds': // Elementary Stream DeScriptor
     2108                    // https://github.com/JamesHeinrich/getID3/issues/414
     2109                    // https://chromium.googlesource.com/chromium/src/media/+/refs/heads/main/formats/mp4/es_descriptor.cc
     2110                    // https://chromium.googlesource.com/chromium/src/media/+/refs/heads/main/formats/mp4/es_descriptor.h
     2111                    $atom_structure['version']   = getid3_lib::BigEndian2Int(substr($atom_data,  0, 1)); // hardcoded: 0x00
     2112                    $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data,  1, 3)); // hardcoded: 0x000000
     2113                    $esds_offset = 4;
     2114
     2115                    $atom_structure['ES_DescrTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1));
     2116                    $esds_offset += 1;
     2117                    if ($atom_structure['ES_DescrTag'] != 0x03) {
     2118                        $this->warning('expecting esds.ES_DescrTag = 0x03, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DescrTag']).'), at offset '.$atom_structure['offset']);
     2119                        break;
     2120                    }
     2121                    $atom_structure['ES_DescrSize'] = $this->quicktime_read_mp4_descr_length($atom_data, $esds_offset);
     2122
     2123                    $atom_structure['ES_ID'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 2));
     2124                    $esds_offset += 2;
     2125                    $atom_structure['ES_flagsraw'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1));
     2126                    $esds_offset += 1;
     2127                    $atom_structure['ES_flags']['stream_dependency'] = (bool) ($atom_structure['ES_flagsraw'] & 0x80);
     2128                    $atom_structure['ES_flags']['url_flag']          = (bool) ($atom_structure['ES_flagsraw'] & 0x40);
     2129                    $atom_structure['ES_flags']['ocr_stream']        = (bool) ($atom_structure['ES_flagsraw'] & 0x20);
     2130                    $atom_structure['ES_stream_priority']            =        ($atom_structure['ES_flagsraw'] & 0x1F);
     2131                    if ($atom_structure['ES_flags']['url_flag']) {
     2132                        $this->warning('Unsupported esds.url_flag enabled at offset '.$atom_structure['offset']);
     2133                        break;
     2134                    }
     2135                    if ($atom_structure['ES_flags']['stream_dependency']) {
     2136                        $atom_structure['ES_dependsOn_ES_ID'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 2));
     2137                        $esds_offset += 2;
     2138                    }
     2139                    if ($atom_structure['ES_flags']['ocr_stream']) {
     2140                        $atom_structure['ES_OCR_ES_Id'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 2));
     2141                        $esds_offset += 2;
     2142                    }
     2143
     2144                    $atom_structure['ES_DecoderConfigDescrTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1));
     2145                    $esds_offset += 1;
     2146                    if ($atom_structure['ES_DecoderConfigDescrTag'] != 0x04) {
     2147                        $this->warning('expecting esds.ES_DecoderConfigDescrTag = 0x04, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DecoderConfigDescrTag']).'), at offset '.$atom_structure['offset']);
     2148                        break;
     2149                    }
     2150                    $atom_structure['ES_DecoderConfigDescrTagSize'] = $this->quicktime_read_mp4_descr_length($atom_data, $esds_offset);
     2151
     2152                    $atom_structure['ES_objectTypeIndication'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1));
     2153                    $esds_offset += 1;
     2154                    // https://stackoverflow.com/questions/3987850
     2155                    // 0x40 = "Audio ISO/IEC 14496-3"                       = MPEG-4 Audio
     2156                    // 0x67 = "Audio ISO/IEC 13818-7 LowComplexity Profile" = MPEG-2 AAC LC
     2157                    // 0x69 = "Audio ISO/IEC 13818-3"                       = MPEG-2 Backward Compatible Audio (MPEG-2 Layers 1, 2, and 3)
     2158                    // 0x6B = "Audio ISO/IEC 11172-3"                       = MPEG-1 Audio (MPEG-1 Layers 1, 2, and 3)
     2159
     2160                    $streamTypePlusFlags = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1));
     2161                    $esds_offset += 1;
     2162                    $atom_structure['ES_streamType'] =        ($streamTypePlusFlags & 0xFC) >> 2;
     2163                    $atom_structure['ES_upStream']   = (bool) ($streamTypePlusFlags & 0x02) >> 1;
     2164                    $atom_structure['ES_bufferSizeDB'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 3));
     2165                    $esds_offset += 3;
     2166                    $atom_structure['ES_maxBitrate'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 4));
     2167                    $esds_offset += 4;
     2168                    $atom_structure['ES_avgBitrate'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 4));
     2169                    $esds_offset += 4;
     2170                    if ($atom_structure['ES_avgBitrate']) {
     2171                        $info['quicktime']['audio']['bitrate'] = $atom_structure['ES_avgBitrate'];
     2172                        $info['audio']['bitrate']              = $atom_structure['ES_avgBitrate'];
     2173                    }
     2174
     2175                    $atom_structure['ES_DecSpecificInfoTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1));
     2176                    $esds_offset += 1;
     2177                    if ($atom_structure['ES_DecSpecificInfoTag'] != 0x05) {
     2178                        $this->warning('expecting esds.ES_DecSpecificInfoTag = 0x05, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DecSpecificInfoTag']).'), at offset '.$atom_structure['offset']);
     2179                        break;
     2180                    }
     2181                    $atom_structure['ES_DecSpecificInfoTagSize'] = $this->quicktime_read_mp4_descr_length($atom_data, $esds_offset);
     2182
     2183                    $atom_structure['ES_DecSpecificInfo'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, $atom_structure['ES_DecSpecificInfoTagSize']));
     2184                    $esds_offset += $atom_structure['ES_DecSpecificInfoTagSize'];
     2185
     2186                    $atom_structure['ES_SLConfigDescrTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1));
     2187                    $esds_offset += 1;
     2188                    if ($atom_structure['ES_SLConfigDescrTag'] != 0x06) {
     2189                        $this->warning('expecting esds.ES_SLConfigDescrTag = 0x05, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_SLConfigDescrTag']).'), at offset '.$atom_structure['offset']);
     2190                        break;
     2191                    }
     2192                    $atom_structure['ES_SLConfigDescrTagSize'] = $this->quicktime_read_mp4_descr_length($atom_data, $esds_offset);
     2193
     2194                    $atom_structure['ES_SLConfigDescr'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, $atom_structure['ES_SLConfigDescrTagSize']));
     2195                    $esds_offset += $atom_structure['ES_SLConfigDescrTagSize'];
     2196                    break;
    21032197
    21042198// AVIF-related - https://docs.rs/avif-parse/0.13.2/src/avif_parse/boxes.rs.html
     
    29923086    }
    29933087
     3088
    29943089    /**
    29953090     * @param array $info
  • trunk/src/wp-includes/ID3/module.audio-video.riff.php

    r54376 r56975  
    215215
    216216                    if (empty($info['playtime_seconds'])) { // may already be set (e.g. DTS-WAV)
    217                         $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $thisfile_audio['bitrate']);
     217                        $info['playtime_seconds'] =  (float)getid3_lib::SafeDiv(($info['avdataend'] - $info['avdataoffset']) * 8, $thisfile_audio['bitrate']);
    218218                    }
    219219
     
    441441                        if (isset($parsedXML['SPEED']['MASTER_SPEED'])) {
    442442                            @list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['MASTER_SPEED']);
    443                             $thisfile_riff_WAVE['iXML'][0]['master_speed'] = $numerator / ($denominator ? $denominator : 1000);
     443                            $thisfile_riff_WAVE['iXML'][0]['master_speed'] = (int) $numerator / ($denominator ? $denominator : 1000);
    444444                        }
    445445                        if (isset($parsedXML['SPEED']['TIMECODE_RATE'])) {
    446446                            @list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['TIMECODE_RATE']);
    447                             $thisfile_riff_WAVE['iXML'][0]['timecode_rate'] = $numerator / ($denominator ? $denominator : 1000);
     447                            $thisfile_riff_WAVE['iXML'][0]['timecode_rate'] = (int) $numerator / ($denominator ? $denominator : 1000);
    448448                        }
    449449                        if (isset($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO']) && !empty($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) && !empty($thisfile_riff_WAVE['iXML'][0]['timecode_rate'])) {
     
    522522                if (!isset($thisfile_audio['bitrate']) && isset($thisfile_riff_audio[$streamindex]['bitrate'])) {
    523523                    $thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
    524                     $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $thisfile_audio['bitrate']);
     524                    $info['playtime_seconds'] = (float)getid3_lib::SafeDiv((($info['avdataend'] - $info['avdataoffset']) * 8), $thisfile_audio['bitrate']);
    525525                }
    526526
     
    532532                    // Reset to the way it was - RIFF parsing will have messed this up
    533533                    $info['avdataend']        = $Original['avdataend'];
    534                     $thisfile_audio['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
     534                    $thisfile_audio['bitrate'] = getid3_lib::SafeDiv(($info['avdataend'] - $info['avdataoffset']) * 8, $info['playtime_seconds']);
    535535
    536536                    $this->fseek($info['avdataoffset'] - 44);
     
    633633                }
    634634                if ($info['avdataend'] > $info['filesize']) {
    635                     switch (!empty($thisfile_audio_dataformat) ? $thisfile_audio_dataformat : '') {
     635                    switch ($thisfile_audio_dataformat) {
    636636                        case 'wavpack': // WavPack
    637637                        case 'lpac':    // LPAC
     
    673673                    }
    674674                }
    675                 if (isset($thisfile_audio_dataformat) && ($thisfile_audio_dataformat == 'ac3')) {
     675                if ($thisfile_audio_dataformat == 'ac3') {
    676676                    unset($thisfile_audio['bits_per_sample']);
    677677                    if (!empty($info['ac3']['bitrate']) && ($info['ac3']['bitrate'] != $thisfile_audio['bitrate'])) {
     
    782782                    $thisfile_riff_video_current = &$thisfile_riff_video[$streamindex];
    783783
    784                     if ($thisfile_riff_raw_avih['dwWidth'] > 0) {
     784                    if ($thisfile_riff_raw_avih['dwWidth'] > 0) { // @phpstan-ignore-line
    785785                        $thisfile_riff_video_current['frame_width'] = $thisfile_riff_raw_avih['dwWidth'];
    786786                        $thisfile_video['resolution_x']             = $thisfile_riff_video_current['frame_width'];
    787787                    }
    788                     if ($thisfile_riff_raw_avih['dwHeight'] > 0) {
     788                    if ($thisfile_riff_raw_avih['dwHeight'] > 0) { // @phpstan-ignore-line
    789789                        $thisfile_riff_video_current['frame_height'] = $thisfile_riff_raw_avih['dwHeight'];
    790790                        $thisfile_video['resolution_y']              = $thisfile_riff_video_current['frame_height'];
    791791                    }
    792                     if ($thisfile_riff_raw_avih['dwTotalFrames'] > 0) {
     792                    if ($thisfile_riff_raw_avih['dwTotalFrames'] > 0) { // @phpstan-ignore-line
    793793                        $thisfile_riff_video_current['total_frames'] = $thisfile_riff_raw_avih['dwTotalFrames'];
    794794                        $thisfile_video['total_frames']              = $thisfile_riff_video_current['total_frames'];
     
    19141914                                        unset($RIFFchunk[$chunkname][$thisindex]);
    19151915                                    }
    1916                                     if (isset($RIFFchunk[$chunkname]) && empty($RIFFchunk[$chunkname])) {
     1916                                    if (count($RIFFchunk[$chunkname]) === 0) {
    19171917                                        unset($RIFFchunk[$chunkname]);
    19181918                                    }
     
    20352035            if (isset($RIFFinfoArray[$key])) {
    20362036                foreach ($RIFFinfoArray[$key] as $commentid => $commentdata) {
    2037                     if (trim($commentdata['data']) != '') {
     2037                    if (!empty($commentdata['data']) && trim($commentdata['data']) != '') {
    20382038                        if (isset($CommentsTargetArray[$value])) {
    20392039                            $CommentsTargetArray[$value][] =     trim($commentdata['data']);
  • trunk/src/wp-includes/ID3/module.audio.mp3.php

    r54376 r56975  
    13811381                            $Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]] = isset($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]) ? ++$Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]] : 1;
    13821382                            if (++$frames_scanned >= $max_frames_scan) {
    1383                                 $pct_data_scanned = ($this->ftell() - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']);
     1383                                $pct_data_scanned = getid3_lib::SafeDiv($this->ftell() - $info['avdataoffset'], $info['avdataend'] - $info['avdataoffset']);
    13841384                                $this->warning('too many MPEG audio frames to scan, only scanned first '.$max_frames_scan.' frames ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.');
    13851385                                foreach ($Distribution as $key1 => $value1) {
    13861386                                    foreach ($value1 as $key2 => $value2) {
    1387                                         $Distribution[$key1][$key2] = round($value2 / $pct_data_scanned);
     1387                                        $Distribution[$key1][$key2] = $pct_data_scanned ? round($value2 / $pct_data_scanned) : 1;
    13881388                                    }
    13891389                                }
     
    14761476        $FirstFrameThisfileInfo = null;
    14771477        while ($SynchSeekOffset < $sync_seek_buffer_size) {
    1478             if ((($avdataoffset + $SynchSeekOffset)  < $info['avdataend']) && !feof($this->getid3->fp)) {
     1478            if ((($avdataoffset + $SynchSeekOffset)  < $info['avdataend']) && !$this->feof()) {
    14791479
    14801480                if ($SynchSeekOffset > $sync_seek_buffer_size) {
     
    14881488                    }
    14891489                    if (empty($info['mpeg'])) {
    1490                         unset($info['mpeg']);
    1491                     }
    1492                     return false;
    1493 
    1494                 } elseif (feof($this->getid3->fp)) {
    1495 
    1496                     $this->error('Could not find valid MPEG audio synch before end of file');
    1497                     if (isset($info['audio']['bitrate'])) {
    1498                         unset($info['audio']['bitrate']);
    1499                     }
    1500                     if (isset($info['mpeg']['audio'])) {
    1501                         unset($info['mpeg']['audio']);
    1502                     }
    1503                     if (isset($info['mpeg']) && (!is_array($info['mpeg']) || (count($info['mpeg']) == 0))) {
    15041490                        unset($info['mpeg']);
    15051491                    }
     
    16531639                                $frames_scanned++;
    16541640                                if ($frames_scan_per_segment && (++$frames_scanned_this_segment >= $frames_scan_per_segment)) {
    1655                                     $this_pct_scanned = ($this->ftell() - $scan_start_offset[$current_segment]) / ($info['avdataend'] - $info['avdataoffset']);
     1641                                    $this_pct_scanned = getid3_lib::SafeDiv($this->ftell() - $scan_start_offset[$current_segment], $info['avdataend'] - $info['avdataoffset']);
    16561642                                    if (($current_segment == 0) && (($this_pct_scanned * $max_scan_segments) >= 1)) {
    16571643                                        // file likely contains < $max_frames_scan, just scan as one segment
     
    17441730        }
    17451731        $info['audio']['channels']        = $info['mpeg']['audio']['channels'];
     1732        if ($info['audio']['channels'] < 1) {
     1733            $this->error('Corrupt MP3 file: no channels');
     1734            return false;
     1735        }
    17461736        $info['audio']['channelmode']     = $info['mpeg']['audio']['channelmode'];
    17471737        $info['audio']['sample_rate']     = $info['mpeg']['audio']['sample_rate'];
  • trunk/src/wp-includes/ID3/module.audio.ogg.php

    r54376 r56975  
    211211
    212212            $info['ogg']['skeleton']['fishead']['version']          = $info['ogg']['skeleton']['fishead']['raw']['version_major'].'.'.$info['ogg']['skeleton']['fishead']['raw']['version_minor'];
    213             $info['ogg']['skeleton']['fishead']['presentationtime'] = $info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'];
    214             $info['ogg']['skeleton']['fishead']['basetime']         = $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator']         / $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator'];
     213            $info['ogg']['skeleton']['fishead']['presentationtime'] = getid3_lib::SafeDiv($info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'], $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator']);
     214            $info['ogg']['skeleton']['fishead']['basetime']         = getid3_lib::SafeDiv($info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'],         $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator']);
    215215            $info['ogg']['skeleton']['fishead']['utc']              = $info['ogg']['skeleton']['fishead']['raw']['utc'];
    216216
     
    289289                $info['audio']['channels']        = $info['flac']['STREAMINFO']['channels'];
    290290                $info['audio']['bits_per_sample'] = $info['flac']['STREAMINFO']['bits_per_sample'];
    291                 $info['playtime_seconds']         = $info['flac']['STREAMINFO']['samples_stream'] / $info['flac']['STREAMINFO']['sample_rate'];
     291                $info['playtime_seconds']         = getid3_lib::SafeDiv($info['flac']['STREAMINFO']['samples_stream'], $info['flac']['STREAMINFO']['sample_rate']);
    292292            }
    293293
     
    360360                }
    361361                if (!empty($info['audio']['sample_rate'])) {
    362                     $info['ogg']['bitrate_average'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['ogg']['samples'] / $info['audio']['sample_rate']);
     362                    $info['ogg']['bitrate_average'] = (($info['avdataend'] - $info['avdataoffset']) * 8) * $info['audio']['sample_rate'] / $info['ogg']['samples'];
    363363                }
    364364            }
     
    535535        $filedata = $this->fread($this->getid3->fread_buffer_size());
    536536        $filedataoffset = 0;
    537         while ((substr($filedata, $filedataoffset++, 4) != 'OggS')) {
     537        while (substr($filedata, $filedataoffset++, 4) != 'OggS') {
    538538            if (($this->ftell() - $oggheader['page_start_offset']) >= $this->getid3->fread_buffer_size()) {
    539539                // should be found before here
    540540                return false;
    541541            }
    542             if ((($filedataoffset + 28) > strlen($filedata)) || (strlen($filedata) < 28)) {
     542            if (($filedataoffset + 28) > strlen($filedata)) {
    543543                if ($this->feof() || (($filedata .= $this->fread($this->getid3->fread_buffer_size())) === '')) {
    544544                    // get some more data, unless eof, in which case fail
  • trunk/src/wp-includes/ID3/module.tag.apetag.php

    r52254 r56975  
    268268                case 'cover art (recording)':
    269269                case 'cover art (studio)':
    270                     // list of possible cover arts from http://taglib-sharp.sourcearchive.com/documentation/2.0.3.0-2/Ape_2Tag_8cs-source.html
     270                    // list of possible cover arts from https://github.com/mono/taglib-sharp/blob/taglib-sharp-2.0.3.2/src/TagLib/Ape/Tag.cs
    271271                    if (is_array($thisfile_ape_items_current['data'])) {
    272272                        $this->warning('APEtag "'.$item_key.'" should be flagged as Binary data, but was incorrectly flagged as UTF-8');
     
    333333                            unset($comments_picture_data);
    334334                        }
    335                     } while (false);
     335                    } while (false); // @phpstan-ignore-line
    336336                    break;
    337337
  • trunk/src/wp-includes/ID3/module.tag.id3v1.php

    r52254 r56975  
    6767                unset($ParsedID3v1['genreid']);
    6868            }
    69             if (isset($ParsedID3v1['genre']) && (empty($ParsedID3v1['genre']) || ($ParsedID3v1['genre'] == 'Unknown'))) {
     69            if (empty($ParsedID3v1['genre']) || ($ParsedID3v1['genre'] == 'Unknown')) {
    7070                unset($ParsedID3v1['genre']);
    7171            }
  • trunk/src/wp-includes/ID3/module.tag.id3v2.php

    r54376 r56975  
    14951495                        }
    14961496                    }
    1497                 } while (false);
     1497                } while (false); // @phpstan-ignore-line
    14981498            }
    14991499
     
    37543754     */
    37553755    public static function IsANumber($numberstring, $allowdecimal=false, $allownegative=false) {
    3756         for ($i = 0; $i < strlen($numberstring); $i++) {
    3757             if ((chr($numberstring[$i]) < chr('0')) || (chr($numberstring[$i]) > chr('9'))) {
    3758                 if (($numberstring[$i] == '.') && $allowdecimal) {
    3759                     // allowed
    3760                 } elseif (($numberstring[$i] == '-') && $allownegative && ($i == 0)) {
    3761                     // allowed
    3762                 } else {
    3763                     return false;
    3764                 }
    3765             }
    3766         }
    3767         return true;
     3756        $pattern  = '#^';
     3757        $pattern .= ($allownegative ? '\\-?' : '');
     3758        $pattern .= '[0-9]+';
     3759        $pattern .= ($allowdecimal  ? '(\\.[0-9]+)?' : '');
     3760        $pattern .= '$#';
     3761        return preg_match($pattern, $numberstring);
    37683762    }
    37693763
     
    37743768     */
    37753769    public static function IsValidDateStampString($datestamp) {
    3776         if (strlen($datestamp) != 8) {
    3777             return false;
    3778         }
    3779         if (!self::IsANumber($datestamp, false)) {
     3770        if (!preg_match('#^[12][0-9]{3}[01][0-9][0123][0-9]$#', $datestamp)) {
    37803771            return false;
    37813772        }
  • trunk/src/wp-includes/ID3/readme.txt

    r52254 r56975  
    2121Mozilla MPL: https://www.mozilla.org/MPL/2.0/                (v2)
    2222
    23 getID3 Commercial License: https://www.getid3.org/#gCL (payment required)
     23getID3 Commercial License: https://www.getid3.org/#gCL
     24(no longer available, existing licenses remain valid)
    2425
    2526*****************************************************************
Note: See TracChangeset for help on using the changeset viewer.