Skip to content

Editor: Decode HTML entities in raw post title input - #76022

Open
Mustafabharmal wants to merge 1 commit into
WordPress:trunkfrom
Mustafabharmal:fix/title-input-decode-html-entities
Open

Mustafabharmal wants to merge 1 commit into
WordPress:trunkfrom
Mustafabharmal:fix/title-input-decode-html-entities

Conversation

@Mustafabharmal

Copy link
Copy Markdown
Contributor

What?

Closes #44445

Applies decodeEntities() to the title value displayed in the raw (code editor) post title input field.

Why?

When a post title contains HTML entities (e.g., &, <, &), the raw post title editor (PostTitleRaw) displays them literally instead of their decoded characters. For example, a title stored as Tom & Jerry shows as Tom & Jerry instead of Tom & Jerry.

The visual editor already handles this correctly because useRichText internally parses the value via RichTextData.fromHTMLString(), which decodes entities. The raw editor, however, passes the title string directly to <TextareaControl>.

How?

Wrapped the title value with decodeEntities() in the PostTitleRaw component before passing it to <TextareaControl>. The decodeEntities import was already present in the file (used for the placeholder).

Testing Instructions

  1. Create a post with a title containing special characters (e.g., Tom & Jerry or A < B)
  2. Save the post
  3. Switch to the Code editor (Cmd/Ctrl+Shift+Alt+M or via Options menu)
  4. Verify the title displays correctly with decoded characters, not raw entities

Screenshots or screencast

Before After
image image

@github-actions github-actions Bot added the [Package] Editor /packages/editor label Feb 27, 2026
@github-actions

github-actions Bot commented Feb 27, 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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @anrghg.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: anrghg.

Co-authored-by: Mustafabharmal <mustafabharmal@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: glendaviesnz <glendaviesnz@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added the [Type] Bug An existing feature does not function as intended label Mar 2, 2026
@Mamaduka

Mamaduka commented Mar 2, 2026

Copy link
Copy Markdown
Member

I think not decoding the title was an intentional choice; decoding will break HTML tags in the titles. This is why the e2e test is failing.

I would recommend checking the original PR for more info - #54718. cc @getdave

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[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.

Title input field to convert HTML special chars

2 participants