Browse Source

use mb_ereg_replace for xmlify and unxmlify

pull/601/head
Zach Prezkuta 8 years ago
parent
commit
c886927a52
1 changed files with 16 additions and 4 deletions
  1. +16
    -4
      include/text.php

+ 16
- 4
include/text.php 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;
}}


Loading…
Cancel
Save