forked from extern/egroupware
"fixed missing encoding for ambersands by using the standard php functions htmlspecialchars and htmlspecialchars_decode"
This commit is contained in:
parent
cb7eb66434
commit
1dd9efb7fb
@ -196,43 +196,21 @@
|
|||||||
*/
|
*/
|
||||||
function xmlrpc_encode_entities($data)
|
function xmlrpc_encode_entities($data)
|
||||||
{
|
{
|
||||||
$convmap = array(0, 0x1F, 0, 0xFFFF, 0x80, 0xFFFF, 0, 0xFFFF);
|
return htmlspecialchars($data,ENT_QUOTES,$GLOBALS['egw']->translation->system_charset ?
|
||||||
$encoding = $GLOBALS['egw']->translation->system_charset;
|
$GLOBALS['egw']->translation->system_charset : 'latin1');
|
||||||
mb_regex_encoding($encoding);
|
}
|
||||||
$pattern = array('<', '>', '"', '\'');
|
|
||||||
$replacement = array('<', '>', '"', ''');
|
if (!function_exists('htmlspecialchars_decode')) // php < 5.1
|
||||||
for ($i=0; $i<sizeof($pattern); $i++) {
|
{
|
||||||
$data = mb_ereg_replace($pattern[$i], $replacement[$i], $data);
|
function htmlspecialchars_decode($text,$quote_style=ENT_COMPAT)
|
||||||
}
|
{
|
||||||
return mb_encode_numericentity($data, $convmap, $encoding);
|
return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS,$quote_style)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function xmlrpc_entity_decode($string)
|
function xmlrpc_entity_decode($string)
|
||||||
{
|
{
|
||||||
$top = split('&', $string);
|
return htmlspecialchars_decode($data,ENT_QUOTES);
|
||||||
$op = '';
|
|
||||||
$i = 0;
|
|
||||||
while($i<sizeof($top))
|
|
||||||
{
|
|
||||||
if (ereg("^([#a-zA-Z0-9]+);", $top[$i], $regs))
|
|
||||||
{
|
|
||||||
$op .= ereg_replace("^[#a-zA-Z0-9]+;",
|
|
||||||
xmlrpc_lookup_entity($regs[1]), $top[$i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($i == 0)
|
|
||||||
{
|
|
||||||
$op = $top[$i];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$op .= '&' . $top[$i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
return $op;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function xmlrpc_lookup_entity($ent)
|
function xmlrpc_lookup_entity($ent)
|
||||||
|
Loading…
Reference in New Issue
Block a user