From 3202f9f37e8624e191acfb5cb748100739dee6f1 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 27 Jun 2019 02:04:17 +0000 Subject: [PATCH] Formatting: Don't convert smilies in ignored tags that have attributes. Smilies in ignored tags are not supposed to be converted to emoji, but this can malfunction if the tag has attributes. For example, the Preformatted block with add a `class` to the `
` tag.

Props pento, jikamens.
Fixes #47489.



git-svn-id: https://develop.svn.wordpress.org/trunk@45569 602fd350-edb4-49c9-b593-d223f7449a82
---
 src/wp-includes/formatting.php             | 2 +-
 tests/phpunit/tests/formatting/Smilies.php | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
index a76a4927b7..334806b9e0 100644
--- a/src/wp-includes/formatting.php
+++ b/src/wp-includes/formatting.php
@@ -3230,7 +3230,7 @@ function convert_smilies( $text ) {
 			$content = $textarr[ $i ];
 
 			// If we're in an ignore block, wait until we find its closing tag
-			if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) {
+			if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches ) ) {
 				$ignore_block_element = $matches[1];
 			}
 
diff --git a/tests/phpunit/tests/formatting/Smilies.php b/tests/phpunit/tests/formatting/Smilies.php
index d1fd3af1a5..662de0b4f6 100644
--- a/tests/phpunit/tests/formatting/Smilies.php
+++ b/tests/phpunit/tests/formatting/Smilies.php
@@ -146,8 +146,8 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase {
 	public function test_ignore_smilies_in_tags( $element ) {
 		$includes_path = includes_url( 'images/smilies/' );
 
-		$in_str  = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . '>My Content Here :?: ';
-		$exp_str = "Do we ingore smilies \xf0\x9f\x98\x89 in $element tags <$element>My Content Here :?: ";
+		$in_str  = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . ' class="foo">My Content Here :?: ';
+		$exp_str = "Do we ingore smilies \xf0\x9f\x98\x89 in $element tags <$element class=\"foo\">My Content Here :?: ";
 
 		// standard smilies, use_smilies: ON
 		update_option( 'use_smilies', 1 );