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
This commit is contained in:
Scott Taylor 2014-06-10 02:03:14 +00:00
parent 66d2144e9a
commit 6cb51c9ceb
2 changed files with 9 additions and 5 deletions

View File

@ -2713,7 +2713,10 @@ function smilies_init() {
*/ */
krsort($wpsmiliestrans); krsort($wpsmiliestrans);
$wp_smiliessearch = '/((?:\s|^)'; $spaces = wp_spaces_regexp();
// Begin first "subpattern"
$wp_smiliessearch = '/(?<=' . $spaces . '|^)';
$subchar = ''; $subchar = '';
foreach ( (array) $wpsmiliestrans as $smiley => $img ) { foreach ( (array) $wpsmiliestrans as $smiley => $img ) {
@ -2723,7 +2726,8 @@ function smilies_init() {
// new subpattern? // new subpattern?
if ($firstchar != $subchar) { if ($firstchar != $subchar) {
if ($subchar != '') { if ($subchar != '') {
$wp_smiliessearch .= ')(?=\s|$))|((?:\s|^)'; ; $wp_smiliessearch .= ')(?=' . $spaces . '|$)'; // End previous "subpattern"
$wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern"
} }
$subchar = $firstchar; $subchar = $firstchar;
$wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:'; $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
@ -2733,7 +2737,7 @@ function smilies_init() {
$wp_smiliessearch .= preg_quote($rest, '/'); $wp_smiliessearch .= preg_quote($rest, '/');
} }
$wp_smiliessearch .= ')(?=\s|$))/m'; $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
} }