Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update getID3 to version 1.9.22. #3383

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/wp-includes/ID3/getid3.lib.php
Expand Up @@ -11,6 +11,13 @@
// ///
/////////////////////////////////////////////////////////////////

if(!defined('GETID3_LIBXML_OPTIONS') && defined('LIBXML_VERSION')) {
if(LIBXML_VERSION >= 20621) {
define('GETID3_LIBXML_OPTIONS', LIBXML_NOENT | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_COMPACT);
} else {
define('GETID3_LIBXML_OPTIONS', LIBXML_NOENT | LIBXML_NONET | LIBXML_NOWARNING);
}
}

class getid3_lib
{
Expand Down Expand Up @@ -303,11 +310,10 @@ public static function BigEndian2Float($byteword) {
}
} elseif (($exponent == 0) && ($fraction == 0)) {
if ($signbit == '1') {
$floatvalue = -0;
$floatvalue = -0.0;
} else {
$floatvalue = 0;
$floatvalue = 0.0;
}
$floatvalue = ($signbit ? 0 : -0);
} elseif (($exponent == 0) && ($fraction != 0)) {
// These are 'unnormalized' values
$floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * self::DecimalBinary2Float($fractionstring);
Expand Down Expand Up @@ -732,7 +738,7 @@ public static function XML2array($XMLstring) {
// This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading is
// disabled by default, but is still needed when LIBXML_NOENT is used.
$loader = @libxml_disable_entity_loader(true);
$XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', LIBXML_NOENT);
$XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', GETID3_LIBXML_OPTIONS);
$return = self::SimpleXMLelement2array($XMLobject);
@libxml_disable_entity_loader($loader);
return $return;
Expand Down
42 changes: 29 additions & 13 deletions src/wp-includes/ID3/getid3.php
Expand Up @@ -182,7 +182,7 @@ class getID3
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
*/
Expand Down Expand Up @@ -387,12 +387,15 @@ class getID3
*/
protected $startup_warning = '';

const VERSION = '1.9.21-202109171300';
const VERSION = '1.9.22-202207161647';
const FREAD_BUFFER_SIZE = 32768;

const ATTACHMENTS_NONE = false;
const ATTACHMENTS_INLINE = true;

/**
* @throws getid3_exception
*/
public function __construct() {

// Check for PHP version
Expand Down Expand Up @@ -569,7 +572,7 @@ public function openfile($filename, $filesize=null, $fp=null) {
$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');
}

Expand Down Expand Up @@ -1055,15 +1058,16 @@ public function GetFileFormatArray() {
'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(
Expand Down Expand Up @@ -1094,7 +1098,7 @@ public function GetFileFormatArray() {

// 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',
Expand Down Expand Up @@ -1551,6 +1555,13 @@ public function GetFileFormat(&$filedata, $filename='') {
$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
Expand Down Expand Up @@ -2198,6 +2209,11 @@ protected function fread($bytes) {
$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);
Expand Down