Skip to content

Emoji: Don't staticize emoji in ignored tags that have attributes. - #13598

Open
praxxiii wants to merge 1 commit into
WordPress:trunkfrom
praxxiii:fix/66134-staticize-emoji-attributes
Open

praxxiii wants to merge 1 commit into
WordPress:trunkfrom
praxxiii:fix/66134-staticize-emoji-attributes

Conversation

@praxxiii

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/66134

Description

Emoji inside ignored tags (code, pre, style, script, textarea) should not be staticized, but wp_staticize_emoji() only recognised such a tag when it closed immediately after the tag name. Tags with attributes — for example the block editor's Code/Preformatted block, which adds class="wp-block-code" to the <pre> tag — were not detected, so emoji inside them were converted to <img>.

Because wp_staticize_emoji() runs on the_content_feed, comment_text_rss, and outgoing mail (wp_staticize_emoji_for_email), this affects RSS/Atom feeds and email — even though the same content is left untouched on the rendered page.

This is the same bug that was fixed for the sibling function convert_smilies() in [45569] / #47489, but that fix was never applied to wp_staticize_emoji().

Fix

Apply the same [^>]* tolerance to the ignore-block regex in wp_staticize_emoji() that convert_smilies() already uses.

Testing

Added unit tests covering all five ignored tags, with and without attributes. The new test fails without the fix and passes with it.

Verified locally against trunk:

  • New test fails on unpatched code (5 failures), passes with the fix.
  • Full Emoji test file passes: 24 tests, 79 assertions.

Emoji inside ignored tags (code, pre, style, script, textarea) should not be
staticized, but wp_staticize_emoji() only recognised such a tag when it closed
immediately after the tag name. Tags with attributes — e.g. the block editor's
Code/Preformatted block, which adds class="wp-block-code" to <pre> — were not
detected, so emoji inside them were converted to <img> in feeds and email.

This applies the same [^>]* tolerance already used by convert_smilies(), whose
identical bug was fixed in [45569] / #47489. Adds unit tests covering all five
ignored tags, with and without attributes.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @praxxiii.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant