Skip to content

Commit

Permalink
Merge pull request #356 from StudioMaX/2.0-update
Browse files Browse the repository at this point in the history
Sync 2.x with 1.9.21-202112151109
  • Loading branch information
StudioMaX authored Dec 15, 2021
2 parents 40bc0ee + 9eec4ca commit ee238d5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 12 deletions.
5 changes: 4 additions & 1 deletion demos/demo.browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@

// Initialize getID3 engine
$getID3 = new GetID3\GetID3;
$getID3->setOption(array('encoding' => $PageEncoding));
$getID3->setOption(array(
'encoding' => $PageEncoding,
'options_audiovideo_quicktime_ReturnAtomData' => true,
));

$getID3checkColor_Head = 'CCCCDD';
$getID3checkColor_DirectoryLight = 'FFCCCC';
Expand Down
11 changes: 9 additions & 2 deletions src/GetID3.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class GetID3
*/
protected $startup_warning = '';

const VERSION = '2.0.x-202109171300';
const VERSION = '2.0.x-202112151109';
const FREAD_BUFFER_SIZE = 32768;

const ATTACHMENTS_NONE = false;
Expand Down Expand Up @@ -922,7 +922,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\\+)',
'module' => 'Audio\\Mpc',
'mime_type' => 'audio/x-musepack',
),
Expand Down Expand Up @@ -1332,6 +1332,13 @@ public function GetFileFormat(&$filedata, $filename='') {
$GetFileFormatArray = $this->GetFileFormatArray();
$info = $GetFileFormatArray['mp3'];
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
2 changes: 1 addition & 1 deletion src/Module/Audio/Mpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function Analyze() {
// this is SV7
return $this->ParseMPCsv7();

} elseif (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', $MPCheaderData)) {
} elseif (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', $MPCheaderData)) {

// this is SV4 - SV6, handle seperately
return $this->ParseMPCsv6();
Expand Down
5 changes: 5 additions & 0 deletions src/Module/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,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 Exception('cannot fread('.$bytes.' from '.$this->ftell().')', 10);
}
$pos = $this->ftell() + $bytes;
if (!Utils::intValueSupported($pos)) {
throw new Exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
Expand Down
2 changes: 1 addition & 1 deletion src/Module/Misc/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function Analyze() {
// "free" object means "deleted", ignore
continue;
}
if (($maxObjLengths[$objectNumber] > 0) && ($maxObjLengths[$objectNumber] < $this->getid3->option_fread_buffer_size)) {
if (!empty($maxObjLengths[$objectNumber]) && ($maxObjLengths[$objectNumber] < $this->getid3->option_fread_buffer_size)) {
// ignore object that are zero-size or >32kB, they are unlikely to contain information we're interested in
$this->fseek($offset);
$objBlob = $this->fread($maxObjLengths[$objectNumber]);
Expand Down
2 changes: 1 addition & 1 deletion src/Module/Tag/ID3v2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2063,7 +2063,7 @@ public function ParseID3v2Frame(&$parsedFrame) {
$parsedFrame['subframes'][] = $subframe;
break;
case 'WXXX':
list($subframe['chapter_url_description'], $subframe['chapter_url']) = explode("\x00", $encoding_converted_text, 2);
@list($subframe['chapter_url_description'], $subframe['chapter_url']) = explode("\x00", $encoding_converted_text, 2);
$parsedFrame['chapter_url'][$subframe['chapter_url_description']] = $subframe['chapter_url'];
$parsedFrame['subframes'][] = $subframe;
break;
Expand Down
8 changes: 4 additions & 4 deletions src/Write/MetaFlac.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function WriteMetaFLAC() {

// On top of that, if error messages are not always captured properly under Windows
// To at least see if there was a problem, compare file modification timestamps before and after writing
clearstatcache();
clearstatcache(true, $this->filename);
$timestampbeforewriting = filemtime($this->filename);

$commandline = Utils::getHelperAppDirectory().'metaflac.exe --no-utf8-convert --remove-all-tags --import-tags-from='.escapeshellarg($tempcommentsfilename);
Expand All @@ -115,7 +115,7 @@ public function WriteMetaFLAC() {
$metaflacError = `$commandline`;

if (empty($metaflacError)) {
clearstatcache();
clearstatcache(true, $this->filename);
if ($timestampbeforewriting == filemtime($this->filename)) {
$metaflacError = 'File modification timestamp has not changed - it looks like the tags were not written';
}
Expand Down Expand Up @@ -162,14 +162,14 @@ public function DeleteMetaFLAC() {

if (file_exists(Utils::getHelperAppDirectory() . 'metaflac.exe')) {
// To at least see if there was a problem, compare file modification timestamps before and after writing
clearstatcache();
clearstatcache(true, $this->filename);
$timestampbeforewriting = filemtime($this->filename);

$commandline = Utils::getHelperAppDirectory() . 'metaflac.exe --remove-all-tags "' . $this->filename . '" 2>&1';
$metaflacError = `$commandline`;

if (empty($metaflacError)) {
clearstatcache();
clearstatcache(true, $this->filename);
if ($timestampbeforewriting == filemtime($this->filename)) {
$metaflacError = 'File modification timestamp has not changed - it looks like the tags were not deleted';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Write/VorbisComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ public function WriteVorbisComment() {

// On top of that, if error messages are not always captured properly under Windows
// To at least see if there was a problem, compare file modification timestamps before and after writing
clearstatcache();
clearstatcache(true, $this->filename);
$timestampbeforewriting = filemtime($this->filename);

$commandline = Utils::getHelperAppDirectory() . 'vorbiscomment.exe -w --raw -c "' . $tempcommentsfilename . '" "' . $this->filename . '" 2>&1';
$VorbiscommentError = `$commandline`;

if (empty($VorbiscommentError)) {
clearstatcache();
clearstatcache(true, $this->filename);
if ($timestampbeforewriting == filemtime($this->filename)) {
$VorbiscommentError = 'File modification timestamp has not changed - it looks like the tags were not written';
}
Expand Down

0 comments on commit ee238d5

Please sign in to comment.