Skip to content

Commit

Permalink
Update XML escape
Browse files Browse the repository at this point in the history
Replace old and likely faulty (XOOPS#419) regex based escape of XML unsafe or illegal characters with more recent PHP built in.
  • Loading branch information
geekwright committed Oct 11, 2015
1 parent 2f1ad40 commit 0f592c4
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions htdocs/class/xml/rpc/xmlrpctag.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public function add(XoopsXmlRpcTag &$tagobj)
$this->_tags[] = $tagobj;
}

abstract function render();

abstract public function render();
}

class XoopsXmlRpcResponse extends XoopsXmlRpcDocument
Expand Down Expand Up @@ -94,14 +93,15 @@ abstract class XoopsXmlRpcTag
protected $_fault = false;

/**
* @param string $text
* encode - make string HTML safe
*
* @param string $text string to encode
*
* @return string
*/
public function encode(&$text)
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;
return htmlspecialchars($text, ENT_XML1, 'UTF-8');
}

/**
Expand All @@ -125,7 +125,7 @@ public function isFault()
* @abstract
* @return void
*/
abstract function render();
abstract public function render();
}

class XoopsXmlRpcFault extends XoopsXmlRpcTag
Expand Down Expand Up @@ -406,5 +406,3 @@ public function render()
return $ret;
}
}

?>

0 comments on commit 0f592c4

Please sign in to comment.