Skip to content

Autocompleters: Don't pre-encode mention search terms#80377

Merged
Mamaduka merged 1 commit into
trunkfrom
fix/autocomplete-non-latin-chars-matching
Jul 17, 2026
Merged

Autocompleters: Don't pre-encode mention search terms#80377
Mamaduka merged 1 commit into
trunkfrom
fix/autocomplete-non-latin-chars-matching

Conversation

@Mamaduka

Copy link
Copy Markdown
Member

What?

See #77185 (comment).

PR fixes the user mention autocompleter (@) to return correct results for non-Latin search terms - Georgian, Japanese, Cyrillic and emoji.

Why?

Both mentions of completers passed search: encodeURIComponent( filterValue ) to getUsers. addQueryArgs already encodes query values, so the term was double-encoded and the server received the literal text %E1%83%90%E1%83%91.

WordPress runs the REST search arg through sanitize_text_field(), which strips every percent-encoded sequence. Latin letters aren't encoded, so they survive, and the bug stays hidden. Non-Latin characters are encoded in full and get erased:

typed server receives after sanitize_text_field
abc abc abc
აბგ %E1%83%90%E1%83%91%E1%83%92 ""

An empty search matches everything, so @აბგ listed every user on the site.

The encoding was correct when the completer built its own query string ('?search=' + encodeURIComponent( search )), but became a double-encode when #33028 moved it to getUsers.

How?

Pass filterValue through unencoded and let addQueryArgs encode it, matching the existing links completer. Same one-line fix in the post and Notes mentions completers.

Testing Instructions

  1. Create a user with a non-Latin display name, e.g. გიორგი მამადაშვილი.
  2. In a paragraph, type @გიორგი.
  3. Only that user is suggested. On the trunk, every user on the site is suggested.

Covered by a new e2e test in autocomplete-and-mentions.spec.js, which fails on trunk.

Use of AI Tools

Assisted by Claude.

@Mamaduka Mamaduka self-assigned this Jul 16, 2026
@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Package] Editor /packages/editor labels Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: noruzzamans <noruzzaman@git.wordpress.org>

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

Size Change: -17 B (0%)

Total Size: 7.73 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 499 kB -17 B (0%)

compressed-size-action

@noruzzamans

Copy link
Copy Markdown
Contributor

Tested and confirmed the fix works as expected.
Before:
before
After:
after

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! It works correctly with both emojis and Japanese.

mention-search.mp4

@Mamaduka Mamaduka added Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jul 17, 2026
@Mamaduka

Copy link
Copy Markdown
Member Author

Thanks for testing. Labeling this for backport, since mentions is a new feature for the notes.

@Mamaduka
Mamaduka merged commit 80f9a92 into trunk Jul 17, 2026
63 checks passed
@Mamaduka
Mamaduka deleted the fix/autocomplete-non-latin-chars-matching branch July 17, 2026 05:20
@github-actions github-actions Bot added this to the Gutenberg 23.7 milestone Jul 17, 2026
@github-actions github-actions Bot removed the Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 17, 2026
gutenbergplugin pushed a commit that referenced this pull request Jul 17, 2026
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: noruzzamans <noruzzaman@git.wordpress.org>
@github-actions

Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.1 branch to get it included in the next release: 2a8a6b9

@github-actions github-actions Bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) Backported to WP Core Pull request that has been successfully merged into WP Core [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants