Do not use lambda functions in wp_kses_decode_entities(), props mdawaffe, fixes #10623

git-svn-id: http://svn.automattic.com/wordpress/trunk@11828 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-08-16 05:58:39 +00:00
parent 62f826c9e5
commit 613aeb5316
1 changed files with 22 additions and 2 deletions

View File

@ -1027,12 +1027,32 @@ function valid_unicode($i) {
* @return string Content after decoded entities
*/
function wp_kses_decode_entities($string) {
$string = preg_replace_callback('/&#([0-9]+);/', create_function('$match', 'return chr($match[1]);'), $string);
$string = preg_replace_callback('/&#[Xx]([0-9A-Fa-f]+);/', create_function('$match', 'return chr(hexdec($match[1]));'), $string);
$string = preg_replace_callback('/&#([0-9]+);/', '_wp_kses_decode_entities_chr', $string);
$string = preg_replace_callback('/&#[Xx]([0-9A-Fa-f]+);/', '_wp_kses_decode_entities_chr_hexdec', $string);
return $string;
}
/**
* Regex callback for wp_kses_decode_entities()
*
* @param array $match preg match
* @return string
*/
function _wp_kses_decode_entities_chr( $match ) {
return chr( $match[1] );
}
/**
* Regex callback for wp_kses_decode_entities()
*
* @param array $match preg match
* @return string
*/
function _wp_kses_decode_entities_chr_hexdec( $match ) {
return chr( hexdec( $match[1] ) );
}
/**
* Sanitize content with allowed HTML Kses rules.
*