Fix issue 41

git-svn-id: http://php-reader.googlecode.com/svn/trunk@215 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2011-04-30 10:37:09 +00:00
parent 7f6e25d59d
commit 27494be163
4 changed files with 19 additions and 33 deletions

View File

@@ -314,12 +314,13 @@ abstract class Zend_Media_Id3_Frame extends Zend_Media_Id3_Object
}
$writer->writeString8(substr($this->_identifier, 0, 4), 4, " ")
->writeUInt32BE($this->_encodeSynchsafe32($size))
->writeUInt32BE($this->getOption('version', 4) < 4 ? $size : $this->_encodeSynchsafe32($size))
->writeUInt16BE($flags);
if (($flags & self::DATA_LENGTH_INDICATOR) ==
self::DATA_LENGTH_INDICATOR) {
$writer->writeUInt32BE($this->_encodeSynchsafe32($this->_size));
$writer->writeUInt32BE
($this->getOption('version', 4) < 4 ? $this->_size : $this->_encodeSynchsafe32($this->_size));
}
$writer->write($data);
}

View File

@@ -285,6 +285,6 @@ final class Zend_Media_Id3_Frame_Apic extends Zend_Media_Id3_Frame
$writer->writeString8($this->_description, 1);
break;
}
$writer->writeString8($this->_imageData);
$writer->write($this->_imageData);
}
}

View File

@@ -81,10 +81,10 @@ final class Zend_Media_Id3_Header extends Zend_Media_Id3_Object
return;
$this->_version = $options['version'] =
$this->_reader->readInt8() + $this->_reader->readInt8() / 10;
$this->_flags = $this->_reader->readInt8();
$this->_size =
$this->_decodeSynchsafe32($this->_reader->readUInt32BE());
$this->_reader->readUInt8() + $this->_reader->readUInt8() / 10;
$this->_flags = $this->_reader->readUInt8();
$this->_size = $this->_version < 4 ?
$this->_reader->readUInt32BE() : $this->_decodeSynchsafe32($this->_reader->readUInt32BE());
}
/**
@@ -171,9 +171,9 @@ final class Zend_Media_Id3_Header extends Zend_Media_Id3_Object
*/
public function write($writer)
{
$writer->writeInt8(floor($this->_version))
->writeInt8(($this->_version - floor($this->_version)) * 10)
->writeInt8($this->_flags)
->writeUInt32BE($this->_encodeSynchsafe32($this->_size));
$writer->writeUInt8(floor($this->_version))
->writeUInt8(($this->_version - floor($this->_version)) * 10)
->writeUInt8($this->_flags)
->writeUInt32BE($this->_version < 4 ? $this->_size : $this->_encodeSynchsafe32($this->_size));
}
}

View File

@@ -172,7 +172,6 @@ abstract class Zend_Media_Id3_Object
/**
* Decodes the given 28-bit synchsafe integer to regular 32-bit integer.
*
* @param integer $val The integer to decode
* @return integer
*/
@@ -188,24 +187,17 @@ abstract class Zend_Media_Id3_Object
* Whenever a false synchronisation is found within the data, one zeroed
* byte is inserted after the first false synchronisation byte. This has the
* side effect that all 0xff00 combinations have to be altered, so they will
* not be affected by the decoding process. Therefore all the 0xff00
* combinations have to be replaced with the 0xff0000 combination during the
* unsynchronisation.
* not be affected by the decoding process.
*
* Therefore all the 0xff00 combinations are replaced with the 0xff0000 combination and all the 0xff[0xe0-0xff]
* combinations are replaced with 0xff00[0xe0-0xff] during the unsynchronisation.
*
* @param string $data The input data.
* @return string
*/
protected final function _encodeUnsynchronisation(&$data)
{
$result = '';
for ($i = 0, $j = 0; $i < strlen($data) - 1; $i++) {
if (ord($data[$i]) == 0xff &&
((($tmp = ord($data[$i + 1])) & 0xe0) == 0xe0 || $tmp == 0x0)) {
$result .= substr($data, $j, $i + 1 - $j) . "\0";
$j = $i + 1;
}
}
return $result . substr($data, $j);
return preg_replace('/\xff(?=[\xe0-\xff])/', "\xff\x00", preg_replace('/\xff\x00/', "\xff\x00\x00", $data));
}
/**
@@ -217,14 +209,7 @@ abstract class Zend_Media_Id3_Object
*/
protected final function _decodeUnsynchronisation(&$data)
{
$result = '';
for ($i = 0, $j = 0; $i < strlen($data) - 1; $i++) {
if (ord($data[$i]) == 0xff && ord($data[$i + 1]) == 0x0) {
$result .= substr($data, $j, $i + 1 - $j);
$j = $i + 2;
}
}
return $result . substr($data, $j);
return preg_replace('/\xff\x00\x00/', "\xff\x00", preg_replace('/\xff\x00(?=[\xe0-\xff])/', "\xff", $data));
}
/**
@@ -263,7 +248,7 @@ abstract class Zend_Media_Id3_Object
*/
protected final function _explodeString8($value, $limit = null)
{
return preg_split("/\\x00/", $value, $limit);
return preg_split('/\x00/', $value, $limit);
}
/**