mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
Circumvent a bug in some distributions of apache/mod_php, where an apache
child, that has executed a php script with mbstring.func_overload=7 once, will overload substr() in a later execution of another php script, even if the Location context of that script has mbstring.func_overload=0 set. Since the WBXML decoder works byte-by-byte to determine substring length, it fails, if mb_substr() is used. This patch prevents this.
This commit is contained in:
parent
e71608d8cc
commit
3304616642
@ -245,7 +245,7 @@ class XML_WBXML_Decoder extends XML_WBXML_ContentHandler {
|
||||
function retrieveStringTable($input)
|
||||
{
|
||||
$size = XML_WBXML::MBUInt32ToInt($input, $this->_strpos);
|
||||
$this->_stringTable = substr($input, $this->_strpos, $size);
|
||||
$this->_stringTable = $this->_substr($input, $this->_strpos, $size);
|
||||
$this->_strpos += $size;
|
||||
// print "stringtable($size):" . $this->_stringTable ."\n";
|
||||
}
|
||||
@ -371,7 +371,7 @@ class XML_WBXML_Decoder extends XML_WBXML_ContentHandler {
|
||||
// Section 5.8.4.6
|
||||
$size = XML_WBXML::MBUInt32ToInt($input, $this->_strpos);
|
||||
// print "opaque of size $size\n"; // @todo remove debug
|
||||
$b = substr($input, $this->_strpos, $size);
|
||||
$b = $this->_substr($input, $this->_strpos, $size);
|
||||
#$b = mb_substr($input, $this->_strpos, $size, 'ISO-8859-1');
|
||||
$this->_strpos += $size;
|
||||
|
||||
@ -542,7 +542,7 @@ class XML_WBXML_Decoder extends XML_WBXML_ContentHandler {
|
||||
case XML_WBXML_GLOBAL_TOKEN_OPAQUE:
|
||||
// Section 5.8.4.6
|
||||
$size = XML_WBXML::MBUInt32ToInt($input, $this->_strpos);
|
||||
$b = substr($input, $this->_strpos, $this->_strpos + $size);
|
||||
$b = $this->_substr($input, $this->_strpos, $this->_strpos + $size);
|
||||
$this->_strpos += $size;
|
||||
|
||||
$value .= $b;
|
||||
@ -664,5 +664,21 @@ class XML_WBXML_Decoder extends XML_WBXML_ContentHandler {
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* imitate substr()
|
||||
* This circumvents a bug in the mbstring overloading in some distributions,
|
||||
* where the mbstring.func_overload=0 INI-setting does not work, if mod_php
|
||||
* has another value for that setting in another directory-context
|
||||
*/
|
||||
function _substr($input,$start,$size)
|
||||
{
|
||||
$ret = "";
|
||||
if (!$input) return $ret;
|
||||
for ($i = $start; $i < $start+$size; $i++) {
|
||||
$ret .= $input[$i];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user