From 6cb51c9ceb0fcc1b875a2ebfef851d7716402f1f Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 10 Jun 2014 02:03:14 +0000 Subject: [PATCH] `smilies_init()`, treat ` ` like whitespace when converting smilies. Adds unit tests. Props miqrogroove. Fixes #27587. Built from https://develop.svn.wordpress.org/trunk@28717 git-svn-id: http://core.svn.wordpress.org/trunk@28531 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 2 +- wp-includes/functions.php | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 8aa6ad721d..a36129767f 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1912,7 +1912,7 @@ function translate_smiley( $matches ) { */ $src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() ); - return sprintf( ' %s ', esc_url( $src_url ), esc_attr( $smiley ) ); + return sprintf( '%s', esc_url( $src_url ), esc_attr( $smiley ) ); } /** diff --git a/wp-includes/functions.php b/wp-includes/functions.php index c62036f7e8..db399cf1e6 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -2713,7 +2713,10 @@ function smilies_init() { */ krsort($wpsmiliestrans); - $wp_smiliessearch = '/((?:\s|^)'; + $spaces = wp_spaces_regexp(); + + // Begin first "subpattern" + $wp_smiliessearch = '/(?<=' . $spaces . '|^)'; $subchar = ''; foreach ( (array) $wpsmiliestrans as $smiley => $img ) { @@ -2723,7 +2726,8 @@ function smilies_init() { // new subpattern? if ($firstchar != $subchar) { if ($subchar != '') { - $wp_smiliessearch .= ')(?=\s|$))|((?:\s|^)'; ; + $wp_smiliessearch .= ')(?=' . $spaces . '|$)'; // End previous "subpattern" + $wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern" } $subchar = $firstchar; $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:'; @@ -2733,7 +2737,7 @@ function smilies_init() { $wp_smiliessearch .= preg_quote($rest, '/'); } - $wp_smiliessearch .= ')(?=\s|$))/m'; + $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m'; } @@ -4419,4 +4423,4 @@ function wp_validate_boolean( $var ) { } return (bool) $var; -} \ No newline at end of file +}