--- a/wp/wp-includes/ID3/module.audio-video.riff.php Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/ID3/module.audio-video.riff.php Fri Sep 05 18:40:08 2025 +0200
@@ -214,7 +214,7 @@
$thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
if (empty($info['playtime_seconds'])) { // may already be set (e.g. DTS-WAV)
- $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $thisfile_audio['bitrate']);
+ $info['playtime_seconds'] = (float)getid3_lib::SafeDiv(($info['avdataend'] - $info['avdataoffset']) * 8, $thisfile_audio['bitrate']);
}
$thisfile_audio['lossless'] = false;
@@ -440,11 +440,11 @@
$thisfile_riff_WAVE['iXML'][0]['parsed'] = $parsedXML;
if (isset($parsedXML['SPEED']['MASTER_SPEED'])) {
@list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['MASTER_SPEED']);
- $thisfile_riff_WAVE['iXML'][0]['master_speed'] = $numerator / ($denominator ? $denominator : 1000);
+ $thisfile_riff_WAVE['iXML'][0]['master_speed'] = (int) $numerator / ($denominator ? $denominator : 1000);
}
if (isset($parsedXML['SPEED']['TIMECODE_RATE'])) {
@list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['TIMECODE_RATE']);
- $thisfile_riff_WAVE['iXML'][0]['timecode_rate'] = $numerator / ($denominator ? $denominator : 1000);
+ $thisfile_riff_WAVE['iXML'][0]['timecode_rate'] = (int) $numerator / ($denominator ? $denominator : 1000);
}
if (isset($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO']) && !empty($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) && !empty($thisfile_riff_WAVE['iXML'][0]['timecode_rate'])) {
$samples_since_midnight = floatval(ltrim($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_HI'].$parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO'], '0'));
@@ -521,7 +521,7 @@
if (!isset($thisfile_audio['bitrate']) && isset($thisfile_riff_audio[$streamindex]['bitrate'])) {
$thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
- $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $thisfile_audio['bitrate']);
+ $info['playtime_seconds'] = (float)getid3_lib::SafeDiv((($info['avdataend'] - $info['avdataoffset']) * 8), $thisfile_audio['bitrate']);
}
if (!empty($info['wavpack'])) {
@@ -531,7 +531,7 @@
// Reset to the way it was - RIFF parsing will have messed this up
$info['avdataend'] = $Original['avdataend'];
- $thisfile_audio['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
+ $thisfile_audio['bitrate'] = getid3_lib::SafeDiv(($info['avdataend'] - $info['avdataoffset']) * 8, $info['playtime_seconds']);
$this->fseek($info['avdataoffset'] - 44);
$RIFFdata = $this->fread(44);
@@ -632,7 +632,7 @@
}
}
if ($info['avdataend'] > $info['filesize']) {
- switch (!empty($thisfile_audio_dataformat) ? $thisfile_audio_dataformat : '') {
+ switch ($thisfile_audio_dataformat) {
case 'wavpack': // WavPack
case 'lpac': // LPAC
case 'ofr': // OptimFROG
@@ -672,7 +672,7 @@
$this->warning('Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored');
}
}
- if (isset($thisfile_audio_dataformat) && ($thisfile_audio_dataformat == 'ac3')) {
+ if ($thisfile_audio_dataformat == 'ac3') {
unset($thisfile_audio['bits_per_sample']);
if (!empty($info['ac3']['bitrate']) && ($info['ac3']['bitrate'] != $thisfile_audio['bitrate'])) {
$thisfile_audio['bitrate'] = $info['ac3']['bitrate'];
@@ -781,15 +781,15 @@
/** @var array $thisfile_riff_video_current */
$thisfile_riff_video_current = &$thisfile_riff_video[$streamindex];
- if ($thisfile_riff_raw_avih['dwWidth'] > 0) {
+ if ($thisfile_riff_raw_avih['dwWidth'] > 0) { // @phpstan-ignore-line
$thisfile_riff_video_current['frame_width'] = $thisfile_riff_raw_avih['dwWidth'];
$thisfile_video['resolution_x'] = $thisfile_riff_video_current['frame_width'];
}
- if ($thisfile_riff_raw_avih['dwHeight'] > 0) {
+ if ($thisfile_riff_raw_avih['dwHeight'] > 0) { // @phpstan-ignore-line
$thisfile_riff_video_current['frame_height'] = $thisfile_riff_raw_avih['dwHeight'];
$thisfile_video['resolution_y'] = $thisfile_riff_video_current['frame_height'];
}
- if ($thisfile_riff_raw_avih['dwTotalFrames'] > 0) {
+ if ($thisfile_riff_raw_avih['dwTotalFrames'] > 0) { // @phpstan-ignore-line
$thisfile_riff_video_current['total_frames'] = $thisfile_riff_raw_avih['dwTotalFrames'];
$thisfile_video['total_frames'] = $thisfile_riff_video_current['total_frames'];
}
@@ -808,6 +808,9 @@
if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) {
$strfData = $thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'];
+ if (!isset($thisfile_riff_raw['strf'][$strhfccType][$streamindex])) {
+ $thisfile_riff_raw['strf'][$strhfccType][$streamindex] = null;
+ }
// shortcut
$thisfile_riff_raw_strf_strhfccType_streamindex = &$thisfile_riff_raw['strf'][$strhfccType][$streamindex];
@@ -1353,10 +1356,10 @@
if (!isset($info['playtime_seconds'])) {
$info['playtime_seconds'] = 0;
}
- if (isset($thisfile_riff_raw['strh'][0]['dwLength']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) {
+ if (isset($thisfile_riff_raw['strh'][0]['dwLength']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) { // @phpstan-ignore-line
// needed for >2GB AVIs where 'avih' chunk only lists number of frames in that chunk, not entire movie
$info['playtime_seconds'] = $thisfile_riff_raw['strh'][0]['dwLength'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
- } elseif (isset($thisfile_riff_raw['avih']['dwTotalFrames']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) {
+ } elseif (isset($thisfile_riff_raw['avih']['dwTotalFrames']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) { // @phpstan-ignore-line
$info['playtime_seconds'] = $thisfile_riff_raw['avih']['dwTotalFrames'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
}
@@ -1579,7 +1582,7 @@
public function ParseRIFF($startoffset, $maxoffset) {
$info = &$this->getid3->info;
- $RIFFchunk = false;
+ $RIFFchunk = array();
$FoundAllChunksWeNeed = false;
$LISTchunkParent = null;
$LISTchunkMaxOffset = null;
@@ -1910,7 +1913,7 @@
if (isset($RIFFchunk[$chunkname][$thisindex]) && empty($RIFFchunk[$chunkname][$thisindex])) {
unset($RIFFchunk[$chunkname][$thisindex]);
}
- if (isset($RIFFchunk[$chunkname]) && empty($RIFFchunk[$chunkname])) {
+ if (count($RIFFchunk[$chunkname]) === 0) {
unset($RIFFchunk[$chunkname]);
}
$RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['data'] = $this->fread($chunksize);
@@ -1934,7 +1937,7 @@
}
}
- return $RIFFchunk;
+ return !empty($RIFFchunk) ? $RIFFchunk : false;
}
/**
@@ -2031,7 +2034,7 @@
foreach ($RIFFinfoKeyLookup as $key => $value) {
if (isset($RIFFinfoArray[$key])) {
foreach ($RIFFinfoArray[$key] as $commentid => $commentdata) {
- if (trim($commentdata['data']) != '') {
+ if (!empty($commentdata['data']) && trim($commentdata['data']) != '') {
if (isset($CommentsTargetArray[$value])) {
$CommentsTargetArray[$value][] = trim($commentdata['data']);
} else {