Conversation
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.
|
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 Unlinked AccountsThe 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. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Trac ticket: https://core.trac.wordpress.org/ticket/66134
Description
Emoji inside ignored tags (
code,pre,style,script,textarea) should not be staticized, butwp_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 addsclass="wp-block-code"to the<pre>tag — were not detected, so emoji inside them were converted to<img>.Because
wp_staticize_emoji()runs onthe_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 towp_staticize_emoji().Fix
Apply the same
[^>]*tolerance to the ignore-block regex inwp_staticize_emoji()thatconvert_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: