Changeset 61253 for trunk/src/wp-includes/ID3/module.audio-video.riff.php
- Timestamp:
- 11/17/2025 10:20:32 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/module.audio-video.riff.php
r56975 r61253 68 68 $RIFFsubtype = substr($RIFFheader, 8, 4); 69 69 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 70 79 switch ($RIFFtype) { 71 72 80 case 'FORM': // AIFF, AIFC 73 81 //$info['fileformat'] = 'aiff'; 74 82 $this->container = 'aiff'; 75 $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);76 83 $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4)); 77 84 break; … … 82 89 //$info['fileformat'] = 'riff'; 83 90 $this->container = 'riff'; 84 $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);85 91 if ($RIFFsubtype == 'RMP3') { 86 92 // RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s … … 99 105 } 100 106 101 $nextRIFFoffset = $Original['avdataoffset'] + 8 +$thisfile_riff['header_size']; // 8 = "RIFF" + 32-bit offset107 $nextRIFFoffset = (int) $Original['avdataoffset'] + 8 + (int) $thisfile_riff['header_size']; // 8 = "RIFF" + 32-bit offset 102 108 while ($nextRIFFoffset < min($info['filesize'], $info['avdataend'])) { 103 109 try { … … 306 312 // Keep only string as far as first null byte, discard rest of fixed-width data 307 313 // 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]; 310 317 } 311 318 … … 473 480 if (substr($value, 0, 3) == '[{"') { 474 481 if ($decoded = @json_decode($value, true)) { 475 if ( !empty($decoded) && (count($decoded) == 1)) {482 if (count($decoded) === 1) { 476 483 $value = $decoded[0]; 477 484 } else { … … 1133 1140 foreach ($CommentsChunkNames as $key => $value) { 1134 1141 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]; 1136 1145 } 1137 1146 } … … 1225 1234 foreach ($CommentsChunkNames as $key => $value) { 1226 1235 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]; 1228 1239 } 1229 1240 } … … 1365 1376 1366 1377 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) { 1368 1379 1369 1380 if (!isset($info['bitrate'])) { … … 1371 1382 } 1372 1383 1373 } elseif ( isset($thisfile_riff_audio) && !isset($thisfile_riff_video)) {1384 } elseif ($thisfile_riff_audio !== null && $thisfile_riff_video === null) { // @phpstan-ignore-line 1374 1385 1375 1386 if (!isset($thisfile_audio['bitrate'])) { … … 1377 1388 } 1378 1389 1379 } elseif ( !isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {1390 } elseif ($thisfile_riff_audio === null && $thisfile_riff_video !== null) { 1380 1391 1381 1392 if (!isset($thisfile_video['bitrate'])) { … … 1602 1613 break; 1603 1614 } 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 } 1607 1627 } 1608 1628 if (($chunksize % 2) != 0) { … … 1694 1714 } 1695 1715 $thisindex = 0; 1696 if (isset($RIFFchunk[$chunkname]) && is_array($RIFFchunk[$chunkname])) {1716 if (isset($RIFFchunk[$chunkname])) { 1697 1717 $thisindex = count($RIFFchunk[$chunkname]); 1698 1718 }
Note: See TracChangeset
for help on using the changeset viewer.