|
|
@@ -51,6 +51,11 @@ class Zend_Amf_Util_BinaryStream
|
|
|
protected $_needle;
|
|
|
|
|
|
/**
|
|
|
+ * @var bool str* functions overloaded using mbstring.func_overload?
|
|
|
+ */
|
|
|
+ protected $_mbStringFunctionsOverloaded;
|
|
|
+
|
|
|
+ /**
|
|
|
* Constructor
|
|
|
*
|
|
|
* Create a reference to a byte stream that is going to be parsed or created
|
|
|
@@ -69,7 +74,8 @@ class Zend_Amf_Util_BinaryStream
|
|
|
|
|
|
$this->_stream = $stream;
|
|
|
$this->_needle = 0;
|
|
|
- $this->_streamLength = strlen($stream);
|
|
|
+ $this->_mbStringFunctionsOverloaded = function_exists('mb_strlen') && (ini_get('mbstring.func_overload') !== '') && ((int)ini_get('mbstring.func_overload') & 2);
|
|
|
+ $this->_streamLength = $this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream);
|
|
|
$this->_bigEndian = (pack('l', 1) === "\x00\x00\x00\x01");
|
|
|
}
|
|
|
|
|
|
@@ -97,7 +103,7 @@ class Zend_Amf_Util_BinaryStream
|
|
|
require_once 'Zend/Amf/Exception.php';
|
|
|
throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
|
|
|
}
|
|
|
- $bytes = substr($this->_stream, $this->_needle, $length);
|
|
|
+ $bytes = $this->_mbStringFunctionsOverloaded ? mb_substr($this->_stream, $this->_needle, $length, '8bit') : substr($this->_stream, $this->_needle, $length);
|
|
|
$this->_needle+= $length;
|
|
|
return $bytes;
|
|
|
}
|
|
|
@@ -184,7 +190,7 @@ class Zend_Amf_Util_BinaryStream
|
|
|
*/
|
|
|
public function writeUtf($stream)
|
|
|
{
|
|
|
- $this->writeInt(strlen($stream));
|
|
|
+ $this->writeInt($this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream));
|
|
|
$this->_stream.= $stream;
|
|
|
return $this;
|
|
|
}
|
|
|
@@ -209,7 +215,7 @@ class Zend_Amf_Util_BinaryStream
|
|
|
*/
|
|
|
public function writeLongUtf($stream)
|
|
|
{
|
|
|
- $this->writeLong(strlen($stream));
|
|
|
+ $this->writeLong($this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream));
|
|
|
$this->_stream.= $stream;
|
|
|
}
|
|
|
|
|
|
@@ -255,7 +261,7 @@ class Zend_Amf_Util_BinaryStream
|
|
|
*/
|
|
|
public function readDouble()
|
|
|
{
|
|
|
- $bytes = substr($this->_stream, $this->_needle, 8);
|
|
|
+ $bytes = $this->_mbStringFunctionsOverloaded ? mb_substr($this->_stream, $this->_needle, 8, '8bit') : substr($this->_stream, $this->_needle, 8);
|
|
|
$this->_needle+= 8;
|
|
|
|
|
|
if (!$this->_bigEndian) {
|