Skip to content

Match custom emoji by shortcode - #4017

Merged
pfefferle merged 2 commits into
trunkfrom
fix/emoji-shortcodes
Nov 5, 2026
Merged

pfefferle merged 2 commits into
trunkfrom
fix/emoji-shortcodes

Conversation

@pfefferle

@pfefferle pfefferle commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Fixes #

Proposed changes:

  • Custom emoji are found by their shortcode (:name:) in one pass over the text, and each one is looked up in the emoji of the post or the actor.
  • A shortcode has letters, digits, _ and -, 2 to 100 characters. Emoji with other names are not stored and stay text.
  • A shortcode needs a space or punctuation around it, so text like 12:30:blobcat: stays as it is.
  • Shortcodes match regardless of case, as before.
  • An author name only prepares the emoji it uses.
  • Emoji blocks in replies are built with core's get_comment_delimited_block_content().

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Reply to a post from an account that has a custom emoji in its display name, and use another custom emoji in the reply: both show as images.
  • Use the shortcode in a different case in the reply (:Blobcat: for :blobcat:): it still shows.
  • npm run env-test -- --filter Test_Emoji

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

@pfefferle pfefferle added Bug Something isn't working [Tests] Includes Tests labels Nov 5, 2026
Copilot AI balanced review requested due to automatic review settings November 5, 2026 08:17
@pfefferle pfefferle self-assigned this Nov 5, 2026
@pfefferle
pfefferle requested a review from a team November 5, 2026 08:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An unmapped shortcode can consume the opening colon of a valid emoji, preventing it from rendering in replies and author names; both replacement paths need a fix and regression coverage.

1 open issue
What changed in this PR

This PR updates custom emoji rendering in replies and author names to use shortcode lookup with a fixed matching pattern.

Changes:

  • Validates shortcode names and preserves case-insensitive matching.
  • Prepares only emoji used in author names and uses WordPress’s block serialization helper for replies.
  • Adds regression tests and a security changelog entry.
File Description
tests/​phpunit/​tests/​includes/​class-test-emoji.php Tests validation, large emoji sets, case-insensitive matching, and unused emoji handling.
includes/​class-emoji.php Adds shared shortcode validation and replacement, filters stored emoji, and updates block serialization.
.github/​changelog/​fix-emoji-replacement Documents improved emoji rendering in names and replies.

Review effort: Balanced

Comment thread includes/class-emoji.php Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the emoji shortcode-handling changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@pfefferle
pfefferle merged commit 91bedac into trunk Nov 5, 2026
14 checks passed
@pfefferle
pfefferle deleted the fix/emoji-shortcodes branch November 5, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants