Skip to content

Notes: mention markup is stripped by kses when a note is created via the REST API #80258

Closed

Description

@adamsilverstein

Description

Follow-up to #79604. The mention kses scoping added there never fires when a note is created through the REST API, so for users without unfiltered_html, the <a class="wp-note-mention user-N"> markup is silently stripped on save.

Neither of the two arming hooks runs on the REST create path:

  • gutenberg_notes_scope_mention_kses_rest() (on rest_preprocess_comment) does not arm because WP_REST_Comments_Controller::create_item() only copies the type param into the prepared data after prepare_item_for_database() has run, so the filter sees no comment type (and no id to resolve one from).
  • The preprocess_comment arm does not fire either, because create_item() inserts via wp_insert_comment( wp_filter_comment( ... ) ) directly and never calls wp_new_comment().

As a result, creating a note with a mention as an author or contributor (or as anyone but a super admin on multisite) strips the mention classes. This breaks mention chips in the UI and will break mention notifications once #79606 lands.

Step-by-step reproduction instructions

  1. As a user without unfiltered_html (e.g. an author) on a post they can edit, open the editor and add a note that @-mentions another user.
  2. Save and reload the post.
  3. The mention renders as a plain link - the wp-note-mention user-N classes have been stripped, so the mention chip is lost.

Expected behaviour

The mention markup survives saving regardless of the user's unfiltered_html capability, and the mention chip renders after reload.

Actual behaviour

kses strips the mention classes on REST note creation, so the mention degrades to a plain link.

Activity

  1. added
    [Type] Bug
    [Feature] Notes
    on Jul 14, 2026
  2. moved this from 🏗️ In Progress to ✅ Done in WordPress 7.1 Editor Taskson Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

[Feature] Notes[Type] Bug

Type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions