diff -r 5e7a0fedabdf -r 877f952ae2bd web/lib/Zend/Amf/Util/BinaryStream.php --- a/web/lib/Zend/Amf/Util/BinaryStream.php Thu Mar 21 17:31:31 2013 +0100 +++ b/web/lib/Zend/Amf/Util/BinaryStream.php Thu Mar 21 19:50:53 2013 +0100 @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Amf * @subpackage Util - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BinaryStream.php 22101 2010-05-04 20:07:13Z matthew $ + * @version $Id: BinaryStream.php 25241 2013-01-22 11:07:36Z frosch $ */ /** @@ -25,7 +25,7 @@ * * @package Zend_Amf * @subpackage Util - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Amf_Util_BinaryStream @@ -51,6 +51,11 @@ 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 @@ $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 @@ 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; } @@ -120,12 +126,18 @@ * Reads a signed byte * * @return int Value is in the range of -128 to 127. + * @throws Zend_Amf_Exception */ public function readByte() { if (($this->_needle + 1) > $this->_streamLength) { require_once 'Zend/Amf/Exception.php'; - throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length); + throw new Zend_Amf_Exception( + 'Buffer underrun at needle position: ' + . $this->_needle + . ' while requesting length: ' + . $this->_streamLength + ); } return ord($this->_stream{$this->_needle++}); @@ -184,7 +196,7 @@ */ 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 +221,7 @@ */ public function writeLongUtf($stream) { - $this->writeLong(strlen($stream)); + $this->writeLong($this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream)); $this->_stream.= $stream; } @@ -255,7 +267,7 @@ */ 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) {