mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-17 02:41:02 +01:00
"fix for bug #445: xmlrpc utf-8 encoding error
Thanks to a fix from Eugene Pivnev"
This commit is contained in:
parent
0820742057
commit
4378a84503
@ -191,42 +191,20 @@
|
||||
* into their equivalent 'charset entity'. Charset entities enumerated this way
|
||||
* are independent of the charset encoding used to transmit them, and all XML
|
||||
* parsers are bound to understand them.
|
||||
*
|
||||
* @author Eugene Pivnev
|
||||
*/
|
||||
function xmlrpc_encode_entities($data)
|
||||
{
|
||||
$length = strlen($data);
|
||||
$escapeddata = "";
|
||||
for($position = 0; $position < $length; $position++)
|
||||
{
|
||||
$character = substr($data, $position, 1);
|
||||
$code = Ord($character);
|
||||
switch($code)
|
||||
{
|
||||
case 34:
|
||||
$character = """;
|
||||
break;
|
||||
case 38:
|
||||
$character = "&";
|
||||
break;
|
||||
case 39:
|
||||
$character = "'";
|
||||
break;
|
||||
case 60:
|
||||
$character = "<";
|
||||
break;
|
||||
case 62:
|
||||
$character = ">";
|
||||
break;
|
||||
default:
|
||||
if($code < 32 || $code > 159)
|
||||
{
|
||||
$character = ("&#".strval($code).";");
|
||||
}
|
||||
break;
|
||||
}
|
||||
$escapeddata .= $character;
|
||||
$convmap = array(0, 0x1F, 0, 0xFFFF, 0x80, 0xFFFF, 0, 0xFFFF);
|
||||
$encoding = $GLOBALS['egw']->translation->system_charset;
|
||||
mb_regex_encoding($encoding);
|
||||
$pattern = array('<', '>', '"', '\'');
|
||||
$replacement = array('<', '>', '"', ''');
|
||||
for ($i=0; $i<sizeof($pattern); $i++) {
|
||||
$data = mb_ereg_replace($pattern[$i], $replacement[$i], $data);
|
||||
}
|
||||
return $escapeddata;
|
||||
return mb_encode_numericentity($data, $convmap, $encoding);
|
||||
}
|
||||
|
||||
function xmlrpc_entity_decode($string)
|
||||
|
Loading…
Reference in New Issue
Block a user