Fix small defects

git-svn-id: http://php-reader.googlecode.com/svn/trunk@131 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2009-01-01 09:26:01 +00:00
parent 813e5bfcd4
commit 5e63b29836

View File

@@ -134,11 +134,12 @@ final class ID3v2
$this->_reader = &$filename; $this->_reader = &$filename;
else else
$this->_reader = new Reader($filename); $this->_reader = new Reader($filename);
if ($this->_reader->readString8(3) != "ID3")
throw new ID3_Exception("File does not contain ID3v2 tag");
$startOffset = $this->_reader->getOffset(); $startOffset = $this->_reader->getOffset();
if ($this->_reader->readString8(3) != "ID3")
throw new ID3_Exception("File does not contain ID3v2 tag");
$this->_header = new ID3_Header($this->_reader, $options); $this->_header = new ID3_Header($this->_reader, $options);
if ($this->_header->getVersion() < 3 || $this->_header->getVersion() > 4) if ($this->_header->getVersion() < 3 || $this->_header->getVersion() > 4)
throw new ID3_Exception throw new ID3_Exception
@@ -161,15 +162,22 @@ final class ID3v2
// Jump off the loop if we reached the end of the tag // Jump off the loop if we reached the end of the tag
if ($offset - $startOffset - 10 >= $this->_header->getSize() - if ($offset - $startOffset - 10 >= $this->_header->getSize() -
($this->hasFooter() ? 10 : 0)) ($this->hasFooter() ? 10 : 0) - /* Min bytes for a header */ 10)
break; break;
// Jump off the loop if we reached the last frame // Jump off the loop if we reached padding
if ($this->_reader->available() < 4 || Transform::fromUInt32BE if (Transform::fromUInt8($identifier = $this->_reader->read(1)) == 0)
($identifier = $this->_reader->read(4)) == 0)
break; break;
$identifier .= $this->_reader->read(3);
// Jump off the loop if we reached invalid entities. This fix is just to
// make things work. Utility called MP3ext does not seem to know what it
// is doing as it uses padding to write its version information there.
if ($identifier == "MP3e")
break;
$this->_reader->setOffset($offset); $this->_reader->setOffset($offset);
if (@fopen($filename = "ID3/Frame/" . if (@fopen($filename = "ID3/Frame/" .
strtoupper($identifier) . ".php", "r", true) !== false) strtoupper($identifier) . ".php", "r", true) !== false)
require_once($filename); require_once($filename);