diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-includes/ID3/getid3.php --- a/wp/wp-includes/ID3/getid3.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-includes/ID3/getid3.php Fri Sep 05 18:40:08 2025 +0200 @@ -182,7 +182,7 @@ public $option_md5_data = false; /** - * Use MD5 of source file if availble - only FLAC and OptimFROG + * Use MD5 of source file if available - only FLAC and OptimFROG * * @var bool */ @@ -387,12 +387,15 @@ */ protected $startup_warning = ''; - const VERSION = '1.9.21-202109171300'; + const VERSION = '1.9.23-202310190849'; const FREAD_BUFFER_SIZE = 32768; const ATTACHMENTS_NONE = false; const ATTACHMENTS_INLINE = true; + /** + * @throws getid3_exception + */ public function __construct() { // Check for PHP version @@ -435,19 +438,19 @@ $this->startup_error .= 'WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", getID3 cannot run with this setting (bitmask 2 (string functions) cannot be set). Recommended to disable entirely.'."\n"; } - // check for magic quotes in PHP < 7.4.0 (when these functions became deprecated) - if (version_compare(PHP_VERSION, '7.4.0', '<')) { + // check for magic quotes in PHP < 5.4.0 (when these options were removed and getters always return false) + if (version_compare(PHP_VERSION, '5.4.0', '<')) { // Check for magic_quotes_runtime if (function_exists('get_magic_quotes_runtime')) { // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_runtimeDeprecated - if (get_magic_quotes_runtime()) { + if (get_magic_quotes_runtime()) { // @phpstan-ignore-line $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"; } } // Check for magic_quotes_gpc if (function_exists('get_magic_quotes_gpc')) { // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_gpcDeprecated - if (get_magic_quotes_gpc()) { + if (get_magic_quotes_gpc()) { // @phpstan-ignore-line $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"; } } @@ -569,7 +572,7 @@ $this->info['php_memory_limit'] = (($this->memory_limit > 0) ? $this->memory_limit : false); // remote files not supported - if (preg_match('#^(ht|f)tp://#', $filename)) { + if (preg_match('#^(ht|f)tps?://#', $filename)) { throw new getid3_exception('Remote files are not supported - please copy the file locally first'); } @@ -1055,15 +1058,16 @@ 'mime_type' => 'audio/x-monkeys-audio', ), -// has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available -// // MOD - audio - MODule (assorted sub-formats) -// 'mod' => array( -// 'pattern' => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)', -// 'group' => 'audio', -// 'module' => 'mod', -// 'option' => 'mod', -// 'mime_type' => 'audio/mod', -// ), + + // MOD - audio - MODule (SoundTracker) + 'mod' => array( + //'pattern' => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)', // has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available + 'pattern' => '^.{1080}(M\\.K\\.)', + 'group' => 'audio', + 'module' => 'mod', + 'option' => 'mod', + 'mime_type' => 'audio/mod', + ), // MOD - audio - MODule (Impulse Tracker) 'it' => array( @@ -1094,7 +1098,7 @@ // MPC - audio - Musepack / MPEGplus 'mpc' => array( - 'pattern' => '^(MPCK|MP\\+|[\\x00\\x01\\x10\\x11\\x40\\x41\\x50\\x51\\x80\\x81\\x90\\x91\\xC0\\xC1\\xD0\\xD1][\\x20-\\x37][\\x00\\x20\\x40\\x60\\x80\\xA0\\xC0\\xE0])', + 'pattern' => '^(MPCK|MP\\+)', 'group' => 'audio', 'module' => 'mpc', 'mime_type' => 'audio/x-musepack', @@ -1464,6 +1468,16 @@ 'fail_ape' => 'ERROR', ), + // XZ - data - XZ compressed data + '7zip' => array( + 'pattern' => '^7z\\xBC\\xAF\\x27\\x1C', + 'group' => 'archive', + 'module' => '7zip', + 'mime_type' => 'application/x-7z-compressed', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + // Misc other formats @@ -1551,6 +1565,13 @@ $info = $GetFileFormatArray['mp3']; $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php'; return $info; + } elseif (preg_match('#\\.mp[cp\\+]$#i', $filename) && preg_match('#[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0]#s', $filedata)) { + // old-format (SV4-SV6) Musepack header that has a very loose pattern match and could falsely match other data (e.g. corrupt mp3) + // only enable this pattern check if the filename ends in .mpc/mpp/mp+ + $GetFileFormatArray = $this->GetFileFormatArray(); + $info = $GetFileFormatArray['mpc']; + $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php'; + return $info; } elseif (preg_match('#\\.cue$#i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) { // there's not really a useful consistent "magic" at the beginning of .cue files to identify them // so until I think of something better, just go by filename if all other format checks fail @@ -1971,7 +1992,7 @@ } $BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate; - $this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed; + $this->info['video']['compression_ratio'] = getid3_lib::SafeDiv($BitrateCompressed, $BitrateUncompressed, 1); return true; } @@ -2177,6 +2198,8 @@ } /** + * @phpstan-impure + * * @return int|bool */ protected function ftell() { @@ -2189,6 +2212,8 @@ /** * @param int $bytes * + * @phpstan-impure + * * @return string|false * * @throws getid3_exception @@ -2198,6 +2223,11 @@ $this->data_string_position += $bytes; return substr($this->data_string, $this->data_string_position - $bytes, $bytes); } + if ($bytes == 0) { + return ''; + } elseif ($bytes < 0) { + throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().')', 10); + } $pos = $this->ftell() + $bytes; if (!getid3_lib::intValueSupported($pos)) { throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10); @@ -2229,6 +2259,8 @@ * @param int $bytes * @param int $whence * + * @phpstan-impure + * * @return int * * @throws getid3_exception @@ -2270,6 +2302,8 @@ } /** + * @phpstan-impure + * * @return string|false * * @throws getid3_exception @@ -2325,6 +2359,8 @@ } /** + * @phpstan-impure + * * @return bool */ protected function feof() {