Make WordPress Core


Ignore:
Timestamp:
11/17/2025 10:20:32 PM (3 months 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ID3/module.audio-video.riff.php

    r56975 r61253  
    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                        }
Note: See TracChangeset for help on using the changeset viewer.