use htmlspecialchars in xmlify and htmlspecialchars_decode in unxmlify

This commit is contained in:
Fabrixxm 2014-01-16 09:08:51 -05:00
parent efbd20310a
commit 1e87f4eb8c

View file

@ -218,14 +218,16 @@ function xmlify($str) {
break; break;
} }
}*/ }*/
/*
$buffer = mb_ereg_replace("&", "&", $str); $buffer = mb_ereg_replace("&", "&", $str);
$buffer = mb_ereg_replace("'", "'", $buffer); $buffer = mb_ereg_replace("'", "'", $buffer);
$buffer = mb_ereg_replace("\"", """, $buffer); $buffer = mb_ereg_replace('"', """, $buffer);
$buffer = mb_ereg_replace("<", "&lt;", $buffer); $buffer = mb_ereg_replace("<", "&lt;", $buffer);
$buffer = mb_ereg_replace(">", "&gt;", $buffer); $buffer = mb_ereg_replace(">", "&gt;", $buffer);
*/
$buffer = htmlspecialchars($str);
$buffer = trim($buffer); $buffer = trim($buffer);
return($buffer); return($buffer);
}} }}
@ -238,11 +240,13 @@ if(! function_exists('unxmlify')) {
function unxmlify($s) { function unxmlify($s) {
// $ret = str_replace('&amp;','&', $s); // $ret = str_replace('&amp;','&', $s);
// $ret = str_replace(array('&lt;','&gt;','&quot;','&apos;'),array('<','>','"',"'"),$ret); // $ret = str_replace(array('&lt;','&gt;','&quot;','&apos;'),array('<','>','"',"'"),$ret);
$ret = mb_ereg_replace('&amp;', '&', $s); /*$ret = mb_ereg_replace('&amp;', '&', $s);
$ret = mb_ereg_replace('&apos;', "'", $ret); $ret = mb_ereg_replace('&apos;', "'", $ret);
$ret = mb_ereg_replace('&quot;', '"', $ret); $ret = mb_ereg_replace('&quot;', '"', $ret);
$ret = mb_ereg_replace('&lt;', "<", $ret); $ret = mb_ereg_replace('&lt;', "<", $ret);
$ret = mb_ereg_replace('&gt;', ">", $ret); $ret = mb_ereg_replace('&gt;', ">", $ret);
*/
$ret = htmlspecialchars_decode($s);
return $ret; return $ret;
}} }}