Skip to content

Commit ae22592

Browse files
committed
Merge tag 'v1.9.21' into 2.0-with-fixes
# Conflicts: # demos/demo.mysqli.php # src/GetID3.php # src/Module/Audio/Mp3.php # src/Module/Tag/ID3v2.php
2 parents 25ee4ca + 36f5dab commit ae22592

File tree

9 files changed

+290
-221
lines changed

9 files changed

+290
-221
lines changed

.github/workflows/continuous-integration.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ jobs:
66
lint:
77
name: "Lint"
88
runs-on: "ubuntu-latest"
9-
continue-on-error: ${{ matrix.experimental }}
109
strategy:
1110
fail-fast: false
1211
matrix:
@@ -20,21 +19,15 @@ jobs:
2019
- "7.3"
2120
- "7.4"
2221
- "8.0"
23-
experimental:
24-
- false
25-
include:
26-
- php-version: "8.1"
27-
experimental: true
28-
composer-options: "--ignore-platform-reqs"
22+
- "8.1"
2923
steps:
3024
- uses: "actions/checkout@v2"
3125
- uses: "shivammathur/setup-php@v2"
3226
with:
3327
php-version: "${{ matrix.php-version }}"
28+
ini-values: error_reporting=-1, display_errors=On
3429
coverage: "none"
3530
- uses: "ramsey/composer-install@v1"
36-
with:
37-
composer-options: "${{ matrix.composer-options }}"
3831
- name: "Run the linter"
3932
run: "composer lint -- --colors"
4033

changelog.txt

+36
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,42 @@
1818
Version History
1919
===============
2020

21+
1.9.21: [2021-09-22] James Heinrich :: 1.9.21-202109171300
22+
» add support for RIFF.guan
23+
¤ add ID3v1 genres 148-191
24+
¤ torrent files easy access key
25+
* bugfix #342 demo.mysqli.php XSS
26+
* bugfix #340 default quicktime.ReturnAtomData=false
27+
* bugfix #338 improved transliterated tag merging
28+
* bugfix #337 PHP 8.1 compatibility
29+
* bugfix #335 PHP 8.1 compatibility
30+
* bugfix #330 QuicktimeContentRatingLookup 'rtng'
31+
* bugfix #328 throw exception if a resource seek fails
32+
* bugfix #326 improved temporary path detection
33+
* bugfix #325 INF/NAN constants instead of float/string
34+
* bugfix #324 Nikon-specific atoms in QuickTime
35+
* bugfix #321 prevent errors on corrupt JPEGs
36+
* bugfix #319 prevent error in ZIP contents MIME detect
37+
* bugfix #315 ID3v2 USLT check for data length
38+
* bugfix #308 silence libxml deprecation warning
39+
* bugfix #304 undefined index: comments
40+
* bugfix #299 decbin type error in PHP8
41+
* bugfix #298 error scanning WAV via file pointer
42+
* bugfix #294 replace IMG_JPG with IMAGETYPE_JPEG
43+
* bugfix #292 PDFs take long time to parse
44+
* bugfix #291 divzero QuickTime with no playable content
45+
* bugfix #290 detect ID3v1 on minimal example files
46+
* bugfix #289 avoid crash on invalid TIFF
47+
* bugfix #287 mp3 CBR detected as VBR
48+
* bugfix #286 corrupt mp3 can cause slow scanning
49+
* bugfix #284 allow "0" as a value in tags
50+
* bugfix #283 array offset on value of type int
51+
* bugfix #277 ID3v2 add new Turkish Lira TRY
52+
* bugfix #270 demo.mysqli.php LONGBLOB
53+
* bugfix #266 fix possible endless loop on PNG
54+
* bugfix #257 undefined variables
55+
* bugfix #207 improved LAME version string parsing
56+
2157
1.9.20: [2020-06-30] James Heinrich :: 1.9.20-202006061653
2258
» add support for DSDIFF audio
2359
» add support for TAK lossess audio

demos/demo.mysqli.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ function SynchronizeAllTags($filename, $synchronizefrom='all', $synchronizeto='A
14951495
} else {
14961496

14971497
echo '<a href="'.htmlentities($_SERVER['PHP_SELF'].'?encoderoptionsdistribution=1').'">Show all Encoder Options</a><hr>';
1498-
echo 'Files with Encoder Options <b>'.$_REQUEST['showtagfiles'].'</b>:<br>';
1498+
echo 'Files with Encoder Options <b>'.htmlentities($_REQUEST['showtagfiles']).'</b>:<br>';
14991499
echo '<table border="1" cellspacing="0" cellpadding="3">';
15001500
while ($row = mysqli_fetch_array($result)) {
15011501
echo '<tr>';

src/GetID3.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class GetID3
226226
*
227227
* @var bool
228228
*/
229-
public $options_audiovideo_quicktime_ReturnAtomData = true;
229+
public $options_audiovideo_quicktime_ReturnAtomData = false;
230230

231231
/** audio-video.quicktime
232232
* return all parsed data from all atoms if true, otherwise just returned parsed metadata
@@ -319,7 +319,7 @@ class GetID3
319319
*/
320320
protected $startup_warning = '';
321321

322-
const VERSION = '2.0.x-202105131611';
322+
const VERSION = '2.0.x-202109171300';
323323
const FREAD_BUFFER_SIZE = 32768;
324324

325325
const ATTACHMENTS_NONE = false;

src/Module/Audio/Mp3.php

+178-169
Large diffs are not rendered by default.

src/Module/AudioVideo/QuickTime.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class QuickTime extends Handler
3131
*
3232
* @var bool
3333
*/
34-
public $ReturnAtomData = true;
34+
public $ReturnAtomData = false;
3535

3636
/** audio-video.quicktime
3737
* return all parsed data from all atoms if true, otherwise just returned parsed metadata
@@ -2094,7 +2094,7 @@ public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset
20942094
* @return array|false
20952095
*/
20962096
public function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
2097-
$atom_structure = false;
2097+
$atom_structure = array();
20982098
$subatomoffset = 0;
20992099
$subatomcounter = 0;
21002100
if ((strlen($atom_data) == 4) && (Utils::BigEndian2Int($atom_data) == 0x00000000)) {
@@ -2112,17 +2112,22 @@ public function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHiera
21122112
$subatomoffset += 4;
21132113
continue;
21142114
}
2115-
return $atom_structure;
2115+
break;
21162116
}
21172117
if (strlen($subatomdata) < ($subatomsize - 8)) {
21182118
// we don't have enough data to decode the subatom.
21192119
// this may be because we are refusing to parse large subatoms, or it may be because this atom had its size set too large
21202120
// so we passed in the start of a following atom incorrectly?
2121-
return $atom_structure;
2121+
break;
21222122
}
21232123
$atom_structure[$subatomcounter++] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms);
21242124
$subatomoffset += $subatomsize;
21252125
}
2126+
2127+
if (empty($atom_structure)) {
2128+
return false;
2129+
}
2130+
21262131
return $atom_structure;
21272132
}
21282133

@@ -2607,8 +2612,9 @@ public function QuicktimeContentRatingLookup($rtng) {
26072612
static $QuicktimeContentRatingLookup = array();
26082613
if (empty($QuicktimeContentRatingLookup)) {
26092614
$QuicktimeContentRatingLookup[0] = 'None';
2615+
$QuicktimeContentRatingLookup[1] = 'Explicit';
26102616
$QuicktimeContentRatingLookup[2] = 'Clean';
2611-
$QuicktimeContentRatingLookup[4] = 'Explicit';
2617+
$QuicktimeContentRatingLookup[4] = 'Explicit (old)';
26122618
}
26132619
return (isset($QuicktimeContentRatingLookup[$rtng]) ? $QuicktimeContentRatingLookup[$rtng] : 'invalid');
26142620
}

src/Module/Handler.php

+18-12
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,25 @@ protected function fseek($bytes, $whence=SEEK_SET) {
180180
$this->data_string_position = $this->data_string_length + $bytes;
181181
break;
182182
}
183-
return 0;
184-
} else {
185-
$pos = $bytes;
186-
if ($whence == SEEK_CUR) {
187-
$pos = $this->ftell() + $bytes;
188-
} elseif ($whence == SEEK_END) {
189-
$pos = $this->getid3->info['filesize'] + $bytes;
190-
}
191-
if (!Utils::intValueSupported($pos)) {
192-
throw new Exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
193-
}
183+
return 0; // fseek returns 0 on success
184+
}
185+
186+
$pos = $bytes;
187+
if ($whence == SEEK_CUR) {
188+
$pos = $this->ftell() + $bytes;
189+
} elseif ($whence == SEEK_END) {
190+
$pos = $this->getid3->info['filesize'] + $bytes;
191+
}
192+
if (!Utils::intValueSupported($pos)) {
193+
throw new Exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
194+
}
195+
196+
// https://github.com/JamesHeinrich/getID3/issues/327
197+
$result = fseek($this->getid3->fp, $bytes, $whence);
198+
if ($result !== 0) { // fseek returns 0 on success
199+
throw new Exception('cannot fseek('.$pos.'). resource/stream does not appear to support seeking', 10);
194200
}
195-
return fseek($this->getid3->fp, $bytes, $whence);
201+
return $result;
196202
}
197203

198204
/**

src/Module/Tag/ID3v2.php

+8-12
Original file line numberDiff line numberDiff line change
@@ -1961,18 +1961,14 @@ public function ParseID3v2Frame(&$parsedFrame) {
19611961
$frame_offset = 0;
19621962
$parsedFrame['peakamplitude'] = Utils::BigEndian2Float(substr($parsedFrame['data'], $frame_offset, 4));
19631963
$frame_offset += 4;
1964-
$rg_track_adjustment = Utils::Dec2Bin(substr($parsedFrame['data'], $frame_offset, 2));
1965-
$frame_offset += 2;
1966-
$rg_album_adjustment = Utils::Dec2Bin(substr($parsedFrame['data'], $frame_offset, 2));
1967-
$frame_offset += 2;
1968-
$parsedFrame['raw']['track']['name'] = Utils::Bin2Dec(substr($rg_track_adjustment, 0, 3));
1969-
$parsedFrame['raw']['track']['originator'] = Utils::Bin2Dec(substr($rg_track_adjustment, 3, 3));
1970-
$parsedFrame['raw']['track']['signbit'] = Utils::Bin2Dec(substr($rg_track_adjustment, 6, 1));
1971-
$parsedFrame['raw']['track']['adjustment'] = Utils::Bin2Dec(substr($rg_track_adjustment, 7, 9));
1972-
$parsedFrame['raw']['album']['name'] = Utils::Bin2Dec(substr($rg_album_adjustment, 0, 3));
1973-
$parsedFrame['raw']['album']['originator'] = Utils::Bin2Dec(substr($rg_album_adjustment, 3, 3));
1974-
$parsedFrame['raw']['album']['signbit'] = Utils::Bin2Dec(substr($rg_album_adjustment, 6, 1));
1975-
$parsedFrame['raw']['album']['adjustment'] = Utils::Bin2Dec(substr($rg_album_adjustment, 7, 9));
1964+
foreach (array('track','album') as $rgad_entry_type) {
1965+
$rg_adjustment_word = Utils::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 2));
1966+
$frame_offset += 2;
1967+
$parsedFrame['raw'][$rgad_entry_type]['name'] = ($rg_adjustment_word & 0xE000) >> 13;
1968+
$parsedFrame['raw'][$rgad_entry_type]['originator'] = ($rg_adjustment_word & 0x1C00) >> 10;
1969+
$parsedFrame['raw'][$rgad_entry_type]['signbit'] = ($rg_adjustment_word & 0x0200) >> 9;
1970+
$parsedFrame['raw'][$rgad_entry_type]['adjustment'] = ($rg_adjustment_word & 0x0100);
1971+
}
19761972
$parsedFrame['track']['name'] = Utils::RGADnameLookup($parsedFrame['raw']['track']['name']);
19771973
$parsedFrame['track']['originator'] = Utils::RGADoriginatorLookup($parsedFrame['raw']['track']['originator']);
19781974
$parsedFrame['track']['adjustment'] = Utils::RGADadjustmentLookup($parsedFrame['raw']['track']['adjustment'], $parsedFrame['raw']['track']['signbit']);

src/Utils.php

+34-11
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,17 @@ public static function BigEndian2String($number, $minbytes=1, $synchsafe=false,
584584
* @return string
585585
*/
586586
public static function Dec2Bin($number) {
587+
if (!is_numeric($number)) {
588+
// https://github.com/JamesHeinrich/getID3/issues/299
589+
trigger_error('TypeError: Dec2Bin(): Argument #1 ($number) must be numeric, '.gettype($number).' given', E_USER_WARNING);
590+
return '';
591+
}
587592
$bytes = array();
588593
while ($number >= 256) {
589-
$bytes[] = (($number / 256) - (floor($number / 256))) * 256;
594+
$bytes[] = (int) (($number / 256) - (floor($number / 256))) * 256;
590595
$number = floor($number / 256);
591596
}
592-
$bytes[] = $number;
597+
$bytes[] = (int) $number;
593598
$binstring = '';
594599
foreach ($bytes as $i => $byte) {
595600
$binstring = (($i == count($bytes) - 1) ? decbin($byte) : str_pad(decbin($byte), 8, '0', STR_PAD_LEFT)).$binstring;
@@ -1665,12 +1670,21 @@ public static function ImageExtFromMime($mime_type) {
16651670
public static function CopyTagsToComments(&$ThisFileInfo, $option_tags_html=true) {
16661671
// Copy all entries from ['tags'] into common ['comments']
16671672
if (!empty($ThisFileInfo['tags'])) {
1668-
if (isset($ThisFileInfo['tags']['id3v1'])) {
1669-
// bubble ID3v1 to the end, if present to aid in detecting bad ID3v1 encodings
1670-
$ID3v1 = $ThisFileInfo['tags']['id3v1'];
1671-
unset($ThisFileInfo['tags']['id3v1']);
1672-
$ThisFileInfo['tags']['id3v1'] = $ID3v1;
1673-
unset($ID3v1);
1673+
1674+
// Some tag types can only support limited character sets and may contain data in non-standard encoding (usually ID3v1)
1675+
// and/or poorly-transliterated tag values that are also in tag formats that do support full-range character sets
1676+
// To make the output more user-friendly, process the potentially-problematic tag formats last to enhance the chance that
1677+
// the first entries in [comments] are the most correct and the "bad" ones (if any) come later.
1678+
// https://github.com/JamesHeinrich/getID3/issues/338
1679+
$processLastTagTypes = array('id3v1','riff');
1680+
foreach ($processLastTagTypes as $processLastTagType) {
1681+
if (isset($ThisFileInfo['tags'][$processLastTagType])) {
1682+
// bubble ID3v1 to the end, if present to aid in detecting bad ID3v1 encodings
1683+
$temp = $ThisFileInfo['tags'][$processLastTagType];
1684+
unset($ThisFileInfo['tags'][$processLastTagType]);
1685+
$ThisFileInfo['tags'][$processLastTagType] = $temp;
1686+
unset($temp);
1687+
}
16741688
}
16751689
foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
16761690
foreach ($tagarray as $tagname => $tagdata) {
@@ -1701,9 +1715,18 @@ public static function CopyTagsToComments(&$ThisFileInfo, $option_tags_html=true
17011715

17021716
} elseif (!is_array($value)) {
17031717

1704-
$newvaluelength = strlen(trim($value));
1718+
$newvaluelength = strlen(trim($value));
1719+
$newvaluelengthMB = mb_strlen(trim($value));
17051720
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1706-
$oldvaluelength = strlen(trim($existingvalue));
1721+
$oldvaluelength = strlen(trim($existingvalue));
1722+
$oldvaluelengthMB = mb_strlen(trim($existingvalue));
1723+
if (($newvaluelengthMB == $oldvaluelengthMB) && ($existingvalue == Utils::iconv_fallback('UTF-8', 'ASCII', $value))) {
1724+
// https://github.com/JamesHeinrich/getID3/issues/338
1725+
// check for tags containing extended characters that may have been forced into limited-character storage (e.g. UTF8 values into ASCII)
1726+
// which will usually display unrepresentable characters as "?"
1727+
$ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
1728+
break;
1729+
}
17071730
if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
17081731
$ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
17091732
break;
@@ -1914,7 +1937,7 @@ public static function truepath($filename) {
19141937
*
19151938
* @return string
19161939
*/
1917-
public static function mb_basename($path, $suffix = null) {
1940+
public static function mb_basename($path, $suffix = '') {
19181941
$splited = preg_split('#/#', rtrim($path, '/ '));
19191942
return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
19201943
}

0 commit comments

Comments
 (0)