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 `<pre>` tag.

Props pento, jikamens.
Fixes #47489.



git-svn-id: https://develop.svn.wordpress.org/trunk@45569 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2019-06-27 02:04:17 +00:00
parent 4512e94f9c
commit 3202f9f37e
2 changed files with 3 additions and 3 deletions

View File

@ -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];
}

View File

@ -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 :?: </' . $element . '>';
$exp_str = "Do we ingore smilies \xf0\x9f\x98\x89 in $element tags <$element>My Content Here :?: </$element>";
$in_str = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . ' class="foo">My Content Here :?: </' . $element . '>';
$exp_str = "Do we ingore smilies \xf0\x9f\x98\x89 in $element tags <$element class=\"foo\">My Content Here :?: </$element>";
// standard smilies, use_smilies: ON
update_option( 'use_smilies', 1 );