XoopsCore
XoopsCore copied to clipboard
class\xml\rpc\xmlrpctag problem with encode
if we give string like '&' as input the encode method returns '&' and not #||amp||#
it seems that the replace is treated twice.
What does this method as to be clarified as it is only a one way of replacing.
public function encode(&$text)
{
$text = preg_replace(array("/\&([a-z\d\#]+)\;/i", "/\&/", "/\#\|\|([a-z\d\#]+)\|\|\#/i"),
array("#||\\1||#", "&", "&\\1;"), str_replace(array("<", ">"), array("<", ">"), $text));
return $text;
}
The xmlrpc code shows its age in lots of ways, and this function is one of them. A replacement is in the pipeline. The unit test needs to be reviewed, as the whole function was replaced with a standards based PHP internal function. It looks possibly like some double encoding work around was used, but it doesn't seem to be standard, so it was ignored.