use mb_ereg_replace for xmlify and unxmlify

This commit is contained in:
Zach Prezkuta 2013-02-06 22:30:27 -07:00
parent 18f71c1050
commit c886927a52

View file

@ -173,7 +173,7 @@ function autoname($len) {
if(! function_exists('xmlify')) {
function xmlify($str) {
$buffer = '';
/* $buffer = '';
$len = mb_strlen($str);
for($x = 0; $x < $len; $x ++) {
@ -205,7 +205,14 @@ function xmlify($str) {
$buffer .= $char;
break;
}
}
}*/
$buffer = mb_ereg_replace("&", "&amp;", $str);
$buffer = mb_ereg_replace("'", "&apos;", $buffer);
$buffer = mb_ereg_replace("\"", "&quot;", $buffer);
$buffer = mb_ereg_replace("<", "&lt;", $buffer);
$buffer = mb_ereg_replace(">", "&gt;", $buffer);
$buffer = trim($buffer);
return($buffer);
}}
@ -215,8 +222,13 @@ function xmlify($str) {
if(! function_exists('unxmlify')) {
function unxmlify($s) {
$ret = str_replace('&amp;','&', $s);
$ret = str_replace(array('&lt;','&gt;','&quot;','&apos;'),array('<','>','"',"'"),$ret);
// $ret = str_replace('&amp;','&', $s);
// $ret = str_replace(array('&lt;','&gt;','&quot;','&apos;'),array('<','>','"',"'"),$ret);
$ret = mb_ereg_replace('&amp;', '&', $s);
$ret = mb_ereg_replace('&apos;', "'", $ret);
$ret = mb_ereg_replace('&quot;', '"', $ret);
$ret = mb_ereg_replace('&lt;', "<", $ret);
$ret = mb_ereg_replace('&gt;', ">", $ret);
return $ret;
}}