From c886927a52dca84a8908bd169e73ab4c72ebedd3 Mon Sep 17 00:00:00 2001 From: Zach Prezkuta Date: Wed, 6 Feb 2013 22:30:27 -0700 Subject: [PATCH] use mb_ereg_replace for xmlify and unxmlify --- include/text.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/include/text.php b/include/text.php index 075d345cb..6f2e977c9 100644 --- a/include/text.php +++ b/include/text.php @@ -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("&", "&", $str); + $buffer = mb_ereg_replace("'", "'", $buffer); + $buffer = mb_ereg_replace("\"", """, $buffer); + $buffer = mb_ereg_replace("<", "<", $buffer); + $buffer = mb_ereg_replace(">", ">", $buffer); + $buffer = trim($buffer); return($buffer); }} @@ -215,8 +222,13 @@ function xmlify($str) { if(! function_exists('unxmlify')) { function unxmlify($s) { - $ret = str_replace('&','&', $s); - $ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret); +// $ret = str_replace('&','&', $s); +// $ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret); + $ret = mb_ereg_replace('&', '&', $s); + $ret = mb_ereg_replace(''', "'", $ret); + $ret = mb_ereg_replace('"', '"', $ret); + $ret = mb_ereg_replace('<', "<", $ret); + $ret = mb_ereg_replace('>', ">", $ret); return $ret; }}