Changeset 56975
- Timestamp:
- 10/20/2023 01:27:56 PM (16 months ago)
- 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 122 122 } 123 123 // 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_minFound124 if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) { 125 125 return true; 126 126 } 127 127 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; 128 140 } 129 141 … … 135 147 public static function DecimalizeFraction($fraction) { 136 148 list($numerator, $denominator) = explode('/', $fraction); 137 return $numerator / ($denominator ? $denominator : 1);149 return (int) $numerator / ($denominator ? $denominator : 1); 138 150 } 139 151 … … 872 884 */ 873 885 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)878 886 $newcharstring = ''; 879 887 if ($bom) { … … 944 952 */ 945 953 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)950 954 $newcharstring = ''; 951 955 $offset = 0; -
trunk/src/wp-includes/ID3/getid3.php
r54376 r56975 388 388 protected $startup_warning = ''; 389 389 390 const VERSION = '1.9.2 2-202207161647';390 const VERSION = '1.9.23-202310190849'; 391 391 const FREAD_BUFFER_SIZE = 32768; 392 392 … … 439 439 } 440 440 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', '<')) { 443 443 // Check for magic_quotes_runtime 444 444 if (function_exists('get_magic_quotes_runtime')) { 445 445 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_runtimeDeprecated 446 if (get_magic_quotes_runtime()) { 446 if (get_magic_quotes_runtime()) { // @phpstan-ignore-line 447 447 $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"; 448 448 } … … 451 451 if (function_exists('get_magic_quotes_gpc')) { 452 452 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_gpcDeprecated 453 if (get_magic_quotes_gpc()) { 453 if (get_magic_quotes_gpc()) { // @phpstan-ignore-line 454 454 $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"; 455 455 } … … 1465 1465 'module' => 'xz', 1466 1466 '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', 1467 1477 'fail_id3' => 'ERROR', 1468 1478 'fail_ape' => 'ERROR', … … 1983 1993 $BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate; 1984 1994 1985 $this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;1995 $this->info['video']['compression_ratio'] = getid3_lib::SafeDiv($BitrateCompressed, $BitrateUncompressed, 1); 1986 1996 return true; 1987 1997 } … … 2189 2199 2190 2200 /** 2201 * @phpstan-impure 2202 * 2191 2203 * @return int|bool 2192 2204 */ … … 2200 2212 /** 2201 2213 * @param int $bytes 2214 * 2215 * @phpstan-impure 2202 2216 * 2203 2217 * @return string|false … … 2246 2260 * @param int $whence 2247 2261 * 2262 * @phpstan-impure 2263 * 2248 2264 * @return int 2249 2265 * … … 2287 2303 2288 2304 /** 2305 * @phpstan-impure 2306 * 2289 2307 * @return string|false 2290 2308 * … … 2342 2360 2343 2361 /** 2362 * @phpstan-impure 2363 * 2344 2364 * @return bool 2345 2365 */ -
trunk/src/wp-includes/ID3/license.txt
r46587 r56975 21 21 Mozilla MPL: https://www.mozilla.org/MPL/2.0/ (v2) 22 22 23 getID3 Commercial License: https://www.getid3.org/#gCL (payment required) 23 getID3 Commercial License: https://www.getid3.org/#gCL 24 (no longer available, existing licenses remain valid) 24 25 25 26 ***************************************************************** -
trunk/src/wp-includes/ID3/module.audio-video.asf.php
r54376 r56975 194 194 195 195 //$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']); 197 197 } 198 198 break; … … 1067 1067 } 1068 1068 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 1070 1070 foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { 1071 1071 if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) { … … 1153 1153 $thisfile_asf_videomedia_currentstream['format_data']['codec_data'] = substr($streamdata['type_specific_data'], $videomediaoffset); 1154 1154 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 1156 1156 foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { 1157 1157 if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) { -
trunk/src/wp-includes/ID3/module.audio-video.matroska.php
r52254 r56975 293 293 $track_info['display_y'] = (isset($trackarray['DisplayHeight']) ? $trackarray['DisplayHeight'] : $trackarray['PixelHeight']); 294 294 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']; } 301 301 302 302 switch ($trackarray['CodecID']) { -
trunk/src/wp-includes/ID3/module.audio-video.quicktime.php
r54376 r56975 153 153 $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); 154 154 } 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); 156 156 } 157 157 … … 161 161 $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); 162 162 } 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); 164 164 } 165 165 … … 169 169 $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); 170 170 } 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); 172 172 } 173 173 … … 333 333 } elseif (isset($value_array['time_to_sample_table'])) { 334 334 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'])) { 336 336 $framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3); 337 337 $framecount = $value_array2['sample_count']; … … 777 777 778 778 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 781 781 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 782 782 … … 806 806 $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2)); 807 807 $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2); 808 809 808 if (substr($atom_structure['sample_description_table'][$i]['data'], 1, 54) == 'application/octet-stream;type=com.parrot.videometadata') { 810 809 // special handling for apparently-malformed (TextMetaDataSampleEntry?) data for some version of Parrot drones … … 894 893 895 894 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 897 897 $info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']); 898 898 $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate']; … … 919 919 break; 920 920 } 921 break; 922 923 default: 921 924 break; 922 925 } … … 1667 1670 $atom_structure['data'] = $atom_data; 1668 1671 $atom_structure['image_mime'] = 'image/jpeg'; 1669 $atom_structure['description'] = isset($descriptions[$atomname]) ? $descriptions[$atomname] : 'Nikon preview image';1672 $atom_structure['description'] = $descriptions[$atomname]; 1670 1673 $info['quicktime']['comments']['picture'][] = array( 1671 1674 'image_mime' => $atom_structure['image_mime'], … … 1684 1687 $makerNoteVersion = ''; 1685 1688 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) { 1687 1690 $makerNoteVersion .= ' '.ord($atom_data[$i]); 1688 1691 } else { … … 2101 2104 break; 2102 2105 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; 2103 2197 2104 2198 // AVIF-related - https://docs.rs/avif-parse/0.13.2/src/avif_parse/boxes.rs.html … … 2992 3086 } 2993 3087 3088 2994 3089 /** 2995 3090 * @param array $info -
trunk/src/wp-includes/ID3/module.audio-video.riff.php
r54376 r56975 215 215 216 216 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']); 218 218 } 219 219 … … 441 441 if (isset($parsedXML['SPEED']['MASTER_SPEED'])) { 442 442 @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); 444 444 } 445 445 if (isset($parsedXML['SPEED']['TIMECODE_RATE'])) { 446 446 @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); 448 448 } 449 449 if (isset($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO']) && !empty($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) && !empty($thisfile_riff_WAVE['iXML'][0]['timecode_rate'])) { … … 522 522 if (!isset($thisfile_audio['bitrate']) && isset($thisfile_riff_audio[$streamindex]['bitrate'])) { 523 523 $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']); 525 525 } 526 526 … … 532 532 // Reset to the way it was - RIFF parsing will have messed this up 533 533 $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']); 535 535 536 536 $this->fseek($info['avdataoffset'] - 44); … … 633 633 } 634 634 if ($info['avdataend'] > $info['filesize']) { 635 switch ( !empty($thisfile_audio_dataformat) ? $thisfile_audio_dataformat : '') {635 switch ($thisfile_audio_dataformat) { 636 636 case 'wavpack': // WavPack 637 637 case 'lpac': // LPAC … … 673 673 } 674 674 } 675 if ( isset($thisfile_audio_dataformat) && ($thisfile_audio_dataformat == 'ac3')) {675 if ($thisfile_audio_dataformat == 'ac3') { 676 676 unset($thisfile_audio['bits_per_sample']); 677 677 if (!empty($info['ac3']['bitrate']) && ($info['ac3']['bitrate'] != $thisfile_audio['bitrate'])) { … … 782 782 $thisfile_riff_video_current = &$thisfile_riff_video[$streamindex]; 783 783 784 if ($thisfile_riff_raw_avih['dwWidth'] > 0) { 784 if ($thisfile_riff_raw_avih['dwWidth'] > 0) { // @phpstan-ignore-line 785 785 $thisfile_riff_video_current['frame_width'] = $thisfile_riff_raw_avih['dwWidth']; 786 786 $thisfile_video['resolution_x'] = $thisfile_riff_video_current['frame_width']; 787 787 } 788 if ($thisfile_riff_raw_avih['dwHeight'] > 0) { 788 if ($thisfile_riff_raw_avih['dwHeight'] > 0) { // @phpstan-ignore-line 789 789 $thisfile_riff_video_current['frame_height'] = $thisfile_riff_raw_avih['dwHeight']; 790 790 $thisfile_video['resolution_y'] = $thisfile_riff_video_current['frame_height']; 791 791 } 792 if ($thisfile_riff_raw_avih['dwTotalFrames'] > 0) { 792 if ($thisfile_riff_raw_avih['dwTotalFrames'] > 0) { // @phpstan-ignore-line 793 793 $thisfile_riff_video_current['total_frames'] = $thisfile_riff_raw_avih['dwTotalFrames']; 794 794 $thisfile_video['total_frames'] = $thisfile_riff_video_current['total_frames']; … … 1914 1914 unset($RIFFchunk[$chunkname][$thisindex]); 1915 1915 } 1916 if ( isset($RIFFchunk[$chunkname]) && empty($RIFFchunk[$chunkname])) {1916 if (count($RIFFchunk[$chunkname]) === 0) { 1917 1917 unset($RIFFchunk[$chunkname]); 1918 1918 } … … 2035 2035 if (isset($RIFFinfoArray[$key])) { 2036 2036 foreach ($RIFFinfoArray[$key] as $commentid => $commentdata) { 2037 if ( trim($commentdata['data']) != '') {2037 if (!empty($commentdata['data']) && trim($commentdata['data']) != '') { 2038 2038 if (isset($CommentsTargetArray[$value])) { 2039 2039 $CommentsTargetArray[$value][] = trim($commentdata['data']); -
trunk/src/wp-includes/ID3/module.audio.mp3.php
r54376 r56975 1381 1381 $Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]] = isset($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]) ? ++$Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]] : 1; 1382 1382 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']); 1384 1384 $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.'); 1385 1385 foreach ($Distribution as $key1 => $value1) { 1386 1386 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; 1388 1388 } 1389 1389 } … … 1476 1476 $FirstFrameThisfileInfo = null; 1477 1477 while ($SynchSeekOffset < $sync_seek_buffer_size) { 1478 if ((($avdataoffset + $SynchSeekOffset) < $info['avdataend']) && ! feof($this->getid3->fp)) {1478 if ((($avdataoffset + $SynchSeekOffset) < $info['avdataend']) && !$this->feof()) { 1479 1479 1480 1480 if ($SynchSeekOffset > $sync_seek_buffer_size) { … … 1488 1488 } 1489 1489 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))) {1504 1490 unset($info['mpeg']); 1505 1491 } … … 1653 1639 $frames_scanned++; 1654 1640 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']); 1656 1642 if (($current_segment == 0) && (($this_pct_scanned * $max_scan_segments) >= 1)) { 1657 1643 // file likely contains < $max_frames_scan, just scan as one segment … … 1744 1730 } 1745 1731 $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 } 1746 1736 $info['audio']['channelmode'] = $info['mpeg']['audio']['channelmode']; 1747 1737 $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate']; -
trunk/src/wp-includes/ID3/module.audio.ogg.php
r54376 r56975 211 211 212 212 $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']); 215 215 $info['ogg']['skeleton']['fishead']['utc'] = $info['ogg']['skeleton']['fishead']['raw']['utc']; 216 216 … … 289 289 $info['audio']['channels'] = $info['flac']['STREAMINFO']['channels']; 290 290 $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']); 292 292 } 293 293 … … 360 360 } 361 361 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']; 363 363 } 364 364 } … … 535 535 $filedata = $this->fread($this->getid3->fread_buffer_size()); 536 536 $filedataoffset = 0; 537 while ( (substr($filedata, $filedataoffset++, 4) != 'OggS')) {537 while (substr($filedata, $filedataoffset++, 4) != 'OggS') { 538 538 if (($this->ftell() - $oggheader['page_start_offset']) >= $this->getid3->fread_buffer_size()) { 539 539 // should be found before here 540 540 return false; 541 541 } 542 if (( ($filedataoffset + 28) > strlen($filedata)) || (strlen($filedata) < 28)) {542 if (($filedataoffset + 28) > strlen($filedata)) { 543 543 if ($this->feof() || (($filedata .= $this->fread($this->getid3->fread_buffer_size())) === '')) { 544 544 // get some more data, unless eof, in which case fail -
trunk/src/wp-includes/ID3/module.tag.apetag.php
r52254 r56975 268 268 case 'cover art (recording)': 269 269 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.html270 // list of possible cover arts from https://github.com/mono/taglib-sharp/blob/taglib-sharp-2.0.3.2/src/TagLib/Ape/Tag.cs 271 271 if (is_array($thisfile_ape_items_current['data'])) { 272 272 $this->warning('APEtag "'.$item_key.'" should be flagged as Binary data, but was incorrectly flagged as UTF-8'); … … 333 333 unset($comments_picture_data); 334 334 } 335 } while (false); 335 } while (false); // @phpstan-ignore-line 336 336 break; 337 337 -
trunk/src/wp-includes/ID3/module.tag.id3v1.php
r52254 r56975 67 67 unset($ParsedID3v1['genreid']); 68 68 } 69 if ( isset($ParsedID3v1['genre']) && (empty($ParsedID3v1['genre']) || ($ParsedID3v1['genre'] == 'Unknown'))) {69 if (empty($ParsedID3v1['genre']) || ($ParsedID3v1['genre'] == 'Unknown')) { 70 70 unset($ParsedID3v1['genre']); 71 71 } -
trunk/src/wp-includes/ID3/module.tag.id3v2.php
r54376 r56975 1495 1495 } 1496 1496 } 1497 } while (false); 1497 } while (false); // @phpstan-ignore-line 1498 1498 } 1499 1499 … … 3754 3754 */ 3755 3755 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); 3768 3762 } 3769 3763 … … 3774 3768 */ 3775 3769 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)) { 3780 3771 return false; 3781 3772 } -
trunk/src/wp-includes/ID3/readme.txt
r52254 r56975 21 21 Mozilla MPL: https://www.mozilla.org/MPL/2.0/ (v2) 22 22 23 getID3 Commercial License: https://www.getid3.org/#gCL (payment required) 23 getID3 Commercial License: https://www.getid3.org/#gCL 24 (no longer available, existing licenses remain valid) 24 25 25 26 *****************************************************************
Note: See TracChangeset
for help on using the changeset viewer.