diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php index fef2fe8e37..0879cd11b0 100644 --- a/wp-admin/import/blogger.php +++ b/wp-admin/import/blogger.php @@ -550,7 +550,7 @@ class Blogger_Import { $post_status = isset( $entry->draft ) ? 'draft' : 'publish'; // Clean up content - $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); + $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content); $post_content = str_replace('
', '
', $post_content); $post_content = str_replace('
', '
', $post_content); @@ -603,7 +603,7 @@ class Blogger_Import { $comment_content = addslashes( $this->no_apos( html_entity_decode( $entry->content ) ) ); // Clean up content - $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); + $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content); $comment_content = str_replace('
', '
', $comment_content); $comment_content = str_replace('
', '
', $comment_content); diff --git a/wp-admin/import/blogware.php b/wp-admin/import/blogware.php index 1adcc1d5d3..afec323c3b 100644 --- a/wp-admin/import/blogware.php +++ b/wp-admin/import/blogware.php @@ -89,7 +89,7 @@ class BW_Import { } // Clean up content - $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); + $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content); $post_content = str_replace('
', '
', $post_content); $post_content = str_replace('
', '
', $post_content); $post_content = $wpdb->escape($post_content); @@ -129,7 +129,7 @@ class BW_Import { $comment_content = $this->unhtmlentities($comment_content); // Clean up content - $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); + $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content); $comment_content = str_replace('
', '
', $comment_content); $comment_content = str_replace('
', '
', $comment_content); $comment_content = $wpdb->escape($comment_content); diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php index d51b798cd8..e1161df439 100644 --- a/wp-admin/import/livejournal.php +++ b/wp-admin/import/livejournal.php @@ -71,7 +71,7 @@ class LJ_Import { $post_content = $this->unhtmlentities($post_content); // Clean up content - $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); + $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content); $post_content = str_replace('
', '
', $post_content); $post_content = str_replace('
', '
', $post_content); $post_content = $wpdb->escape($post_content); @@ -107,7 +107,7 @@ class LJ_Import { $comment_content = $this->unhtmlentities($comment_content); // Clean up content - $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); + $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content); $comment_content = str_replace('
', '
', $comment_content); $comment_content = str_replace('
', '
', $comment_content); $comment_content = $wpdb->escape($comment_content); diff --git a/wp-admin/import/rss.php b/wp-admin/import/rss.php index d672b064c9..832396f50e 100644 --- a/wp-admin/import/rss.php +++ b/wp-admin/import/rss.php @@ -103,7 +103,7 @@ class RSS_Import { } // Clean up content - $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); + $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content); $post_content = str_replace('
', '
', $post_content); $post_content = str_replace('
', '
', $post_content); diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php index 86b7a07874..762ccb3f2c 100644 --- a/wp-admin/import/wordpress.php +++ b/wp-admin/import/wordpress.php @@ -381,12 +381,12 @@ class WP_Import { $post_author = $this->get_tag( $post, 'dc:creator' ); $post_excerpt = $this->get_tag( $post, 'excerpt:encoded' ); - $post_excerpt = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_excerpt); + $post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_excerpt); $post_excerpt = str_replace('
', '
', $post_excerpt); $post_excerpt = str_replace('
', '
', $post_excerpt); $post_content = $this->get_tag( $post, 'content:encoded' ); - $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); + $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content); $post_content = str_replace('
', '
', $post_content); $post_content = str_replace('
', '
', $post_content); diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 4cc02b27ff..90729796de 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1317,8 +1317,7 @@ function wp_iso_descrambler($string) { return $string; } else { $subject = str_replace('_', ' ', $matches[2]); - /** @todo use preg_replace_callback() */ - $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject); + $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', create_function('$match', 'return chr(hexdec(strtolower($match[1])));'), $subject); return $subject; } } diff --git a/wp-includes/kses.php b/wp-includes/kses.php index c333d4c319..634cd4931e 100644 --- a/wp-includes/kses.php +++ b/wp-includes/kses.php @@ -394,8 +394,11 @@ function wp_kses_version() { * @return string Content with fixed HTML tags */ function wp_kses_split($string, $allowed_html, $allowed_protocols) { - return preg_replace('%((|$))|(<[^>]*(>|$)|>))%e', - "wp_kses_split2('\\1', \$allowed_html, ".'$allowed_protocols)', $string); + global $pass_allowed_html, $pass_allowed_protocols; + $pass_allowed_html = $allowed_html; + $pass_allowed_protocols = $allowed_protocols; + return preg_replace_callback('%((|$))|(<[^>]*(>|$)|>))%', + create_function('$match', 'global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols);'), $string); } /** @@ -999,8 +1002,8 @@ function valid_unicode($i) { * @return string Content after decoded entities */ function wp_kses_decode_entities($string) { - $string = preg_replace('/&#([0-9]+);/e', 'chr("\\1")', $string); - $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+);/e', 'chr(hexdec("\\1"))', $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); return $string; } diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 0da75e7833..8db1f196b0 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -223,7 +223,7 @@ function get_the_content($more_link_text = null, $stripteaser = 0, $more_file = } if ( $preview ) // preview fix for javascript bug with foreign languages - $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); + $output = preg_replace_callback('/\%u([0-9A-F]{4})/', create_function('$match', 'return "&#" . base_convert($match[1], 16, 10) . ";";'), $output); return $output; }