Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/JamesHeinrich/getID3
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHeinrich committed Jan 3, 2022
2 parents e1e92b1 + 73a25a8 commit 46346ff
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
34 changes: 26 additions & 8 deletions getid3/module.graphic.gif.php
Expand Up @@ -17,6 +17,7 @@
/**
* @link https://www.w3.org/Graphics/GIF/spec-gif89a.txt
* @link http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp
* @link http://www.vurdalakov.net/misc/gif/netscape-looping-application-extension
*/

if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
Expand Down Expand Up @@ -168,14 +169,31 @@ public function Analyze() {
$ExtensionBlock['byte_length'] = getid3_lib::LittleEndian2Int(substr($ExtensionBlockData, 2, 1));
$ExtensionBlock['data'] = (($ExtensionBlock['byte_length'] > 0) ? $this->fread($ExtensionBlock['byte_length']) : null);

if (substr($ExtensionBlock['data'], 0, 11) == 'NETSCAPE2.0') { // Netscape Application Block (NAB)
$ExtensionBlock['data'] .= $this->fread(4);
if (substr($ExtensionBlock['data'], 11, 2) == "\x03\x01") {
$info['gif']['animation']['animated'] = true;
$info['gif']['animation']['loop_count'] = getid3_lib::LittleEndian2Int(substr($ExtensionBlock['data'], 13, 2));
} else {
$this->warning('Expecting 03 01 at offset '.($this->ftell() - 4).', found "'.getid3_lib::PrintHexBytes(substr($ExtensionBlock['data'], 11, 2)).'"');
}
switch ($ExtensionBlock['function_code']) {
case 0xFF:
// Application Extension
if ($ExtensionBlock['byte_length'] != 11) {
$this->warning('Expected block size of the Application Extension is 11 bytes, found '.$ExtensionBlock['byte_length'].' at offset '.$this->ftell());
break;
}

if (substr($ExtensionBlock['data'], 0, 11) !== 'NETSCAPE2.0'
&& substr($ExtensionBlock['data'], 0, 11) !== 'ANIMEXTS1.0'
) {
$this->warning('Ignoring unsupported Application Extension '.substr($ExtensionBlock['data'], 0, 11));
break;
}

// Netscape Application Block (NAB)
$ExtensionBlock['data'] .= $this->fread(4);
if (substr($ExtensionBlock['data'], 11, 2) == "\x03\x01") {
$info['gif']['animation']['animated'] = true;
$info['gif']['animation']['loop_count'] = getid3_lib::LittleEndian2Int(substr($ExtensionBlock['data'], 13, 2));
} else {
$this->warning('Expecting 03 01 at offset '.($this->ftell() - 4).', found "'.getid3_lib::PrintHexBytes(substr($ExtensionBlock['data'], 11, 2)).'"');
}

break;
}

if ($this->getid3->option_extra_info) {
Expand Down
2 changes: 1 addition & 1 deletion getid3/module.misc.cue.php
Expand Up @@ -73,7 +73,7 @@ public function readCueSheetFilename($filename)
public function readCueSheet(&$filedata)
{
$cue_lines = array();
foreach (explode("\n", str_replace("\r", null, $filedata)) as $line)
foreach (explode("\n", str_replace("\r", '', $filedata)) as $line)
{
if ( (strlen($line) > 0) && ($line[0] != '#'))
{
Expand Down

0 comments on commit 46346ff

Please sign in to comment.