Autocompleters: Don't pre-encode mention search terms#80377
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: -17 B (0%) Total Size: 7.73 MB 📦 View Changed
|
t-hamano
left a comment
There was a problem hiding this comment.
LGTM! It works correctly with both emojis and Japanese.
mention-search.mp4
|
Thanks for testing. Labeling this for backport, since mentions is a new feature for the notes. |
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>
|
I just cherry-picked this PR to the wp/7.1 branch to get it included in the next release: 2a8a6b9 |


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 )togetUsers.addQueryArgsalready 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
searcharg throughsanitize_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:sanitize_text_fieldabcabcabcაბგ%E1%83%90%E1%83%91%E1%83%92""An empty
searchmatches 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 togetUsers.How?
Pass
filterValuethrough unencoded and letaddQueryArgsencode it, matching the existinglinkscompleter. Same one-line fix in the post and Notes mentions completers.Testing Instructions
გიორგი მამადაშვილი.@გიორგი.Covered by a new e2e test in
autocomplete-and-mentions.spec.js, which fails on trunk.Use of AI Tools
Assisted by Claude.