Eliminate preg_replace with /e. Props tbaboon. fixes #8689

git-svn-id: https://develop.svn.wordpress.org/trunk@11098 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2009-04-27 16:17:24 +00:00
parent eedcfbbc2b
commit 89afda412e
2 changed files with 31 additions and 6 deletions

View File

@@ -772,6 +772,18 @@ function convert_chars($content, $deprecated = '') {
return $content;
}
/**
* Callback used to change %uXXXX to &#YYY; syntax
*
* @since 2.8?
*
* @param array $matches Single Match
* @return string An HTML entity
*/
function funky_javascript_callback($matches) {
return "&#".base_convert($matches[1],16,10).";";
}
/**
* Fixes javascript bugs in browsers.
*
@@ -788,9 +800,10 @@ function funky_javascript_fix($text) {
// Fixes for browsers' javascript bugs
global $is_macIE, $is_winIE;
/** @todo use preg_replace_callback() instead */
if ( $is_winIE || $is_macIE )
$text = preg_replace("/\%u([0-9A-F]{4,4})/e", "'&#'.base_convert('\\1',16,10).';'", $text);
$text = preg_replace_callback("/\%u([0-9A-F]{4,4})/",
"funky_javascript_callback",
$text);
return $text;
}