Permalink
Browse files

Optimizing Sanitize::html() to use str_replace instead of preg_replace.

  • Loading branch information...
1 parent b68d2a3 commit a9e1d0d7ff26aa51a9a6b04242ea8e9f7ac91532 @markstory markstory committed Dec 29, 2009
Showing with 2 additions and 2 deletions.
  1. +2 −2 cake/libs/sanitize.php
View
@@ -90,9 +90,9 @@ function html($string, $remove = false) {
if ($remove) {
$string = strip_tags($string);
} else {
- $patterns = array("/\&/", "/%/", "/</", "/>/", '/"/', "/'/", "/\(/", "/\)/", "/\+/", "/-/");
+ $patterns = array('&', '%', '<', '>', '"', "'", '(', ')', '+', '-');
$replacements = array("&amp;", "&#37;", "&lt;", "&gt;", "&quot;", "&#39;", "&#40;", "&#41;", "&#43;", "&#45;");
- $string = preg_replace($patterns, $replacements, $string);
+ $string = str_replace($patterns, $replacements, $string);
}
return $string;
}

0 comments on commit a9e1d0d

Please sign in to comment.