XoopsCore icon indicating copy to clipboard operation
XoopsCore copied to clipboard

class\xml\rpc\xmlrpctag problem with encode

Open alain91 opened this issue 9 years ago • 1 comments

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||#", "&amp;", "&\\1;"), str_replace(array("<", ">"), array("&lt;", "&gt;"), $text));
        return $text;
    }


alain91 avatar Oct 11 '15 11:10 alain91

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.

geekwright avatar Oct 11 '15 16:10 geekwright