Skip to content
Permalink
Browse files

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.
Merges [45569] to the 5.2 branch.
Fixes #47489.

git-svn-id: https://develop.svn.wordpress.org/branches/5.2@45837 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
SergeyBiryukov committed Aug 19, 2019
1 parent 1df49d0 commit 1bce8ed2cc08a740def4fe18d64dde5b1a3ec415
Showing with 3 additions and 3 deletions.
  1. +1 −1 src/wp-includes/formatting.php
  2. +2 −2 tests/phpunit/tests/formatting/Smilies.php
@@ -3228,7 +3228,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];
}
@@ -146,8 +146,8 @@ public function get_smilies_ignore_tags() {
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 );

0 comments on commit 1bce8ed

Please sign in to comment.
You can’t perform that action at this time.