From 613aeb53161aa5cd29ea7b1af59f44899bf766d4 Mon Sep 17 00:00:00 2001 From: azaozz Date: Sun, 16 Aug 2009 05:58:39 +0000 Subject: [PATCH] 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 --- wp-includes/kses.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/wp-includes/kses.php b/wp-includes/kses.php index 425512861..30f6b7238 100644 --- a/wp-includes/kses.php +++ b/wp-includes/kses.php @@ -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. *