From 4bce27562bb16798a6449c6920be8638bc246736 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Thu, 12 Oct 2006 10:14:14 +0000 Subject: [PATCH] Somewhat stricter smilies replacements by Nazgul. fixes #3222 git-svn-id: https://develop.svn.wordpress.org/trunk@4380 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/formatting.php | 9 ++++++++- wp-includes/vars.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 5c96044432..cb0b8eb950 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -618,7 +618,14 @@ function convert_smilies($text) { if (get_option('use_smilies')) { // HTML loop taken from texturize function, could possible be consolidated $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between - $output = implode('', preg_replace($wp_smiliessearch, $wp_smiliesreplace, $textarr)); + $stop = count($textarr);// loop stuff + for ($i = 0; $i < $stop; $i++) { + $content = $textarr[$i]; + if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag + $content = preg_replace($wp_smiliessearch, $wp_smiliesreplace, $content); + } + $output .= $content; + } } else { // return default text. $output = $text; diff --git a/wp-includes/vars.php b/wp-includes/vars.php index 5bf28078f0..9f8b225717 100644 --- a/wp-includes/vars.php +++ b/wp-includes/vars.php @@ -87,7 +87,7 @@ if (!isset($wpsmiliestrans)) { // generates smilies' search & replace arrays foreach($wpsmiliestrans as $smiley => $img) { - $wp_smiliessearch[] = '/(\s|^|[^<])?'.preg_quote($smiley, '/').'(\b|\s|$)/'; + $wp_smiliessearch[] = '/(\s|^)'.preg_quote($smiley, '/').'(\s|$)/'; $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES); $wp_smiliesreplace[] = " $smiley_masked "; }