Make WordPress Core

Opened 4 years ago

Last modified 15 months ago

#55714 reopened defect (bug)

& stored as & for Post Title and Excerpt in Editor

Reported by: kapilpaul Owned by:
Priority: normal Milestone: Awaiting Review
Component: Editor Version:
Severity: normal Keywords: has-test-info has-screenshots
Cc: Focuses:

Description

Hi,

When an Author/other user(who have Create post permission) creates a post and add a post title as Hello & Welcome to WordPress after save the post the post title is stored as Hello & Welcome to WordPress in DB. As this is stored like this it is showing same in the editor. This is happening with Excerpt also.

NB: This is not happening with Admin user or if you are using Gutenberg Editor.

Reproduce Steps:

  1. Disable your gutenberg editor and enable classic editor.
  2. Logged in as an Author.
  3. Switch to a non block based theme. (skip if your theme is not block based)
  4. Go to Post > Add New
  5. Add Post Title, Excerpt as Hello & Welcome to WordPress
  6. Save Post
  7. You will see Hello & Welcome to WordPress as title

Attachments (2)

classic-editor-ampersand-title-before-saving.png​ (48.4 KB ) - added by sabernhardt 15 months ago.
title in the editor, before saving the post
classic-editor-ampersand-title-after-saving.png​ (56.9 KB ) - added by sabernhardt 15 months ago.
title shows & in the editor after saving the post

Download all attachments as: .zip

Change History (15)

#1 @costdev
4 years ago

  • Version trunk

Removing trunk as the Version as I also reproduced this in WordPress 4.8. This may have been occurring for longer though, I just haven't tested less than 4.8.

#2 @costdev
4 years ago

  • Keywords has-testing-info added

#3 @kapilpaul
4 years ago

There is a security concern while storing the title in DB.
So can we do one thing here, just decode the html entity while displaying in editor?
if that something make sense. so that we do not need work on the existing implementation.

#4 @wordpressdotorg
17 months ago

  • Keywords has-test-info added; has-testing-info removed

#5 @poena
15 months ago

  • Keywords close added
  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → closed

Hi
If this, as described, only happens in the classic editor, then the issue needs to be opened in the repository for the classic editor plugin, not WordPress core Trac.

​https://github.com/WordPress/classic-editor

#6 @johnbillion
15 months ago

@poena The Classic Editor plugin provides the ability to switch back to the classic editor. The functionality itself remains in WordPress core. Am I missing something?

#7 @poena
15 months ago

  • Keywords close removed
  • Resolution invalid
  • Status closed → reopened

No, you are absolutely right, I don't know what I was thinking (maybe wishful thinking ;) )

#8 @sabernhardt
15 months ago

  • Milestone → Awaiting Review

#9 @sukhendu2002
15 months ago

  • Keywords has-screenshots added

Reproduction Report

Description

This report validates whether the issue can be reproduced.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.29.0
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 137.0.0.0
  • OS: macOS
  • Theme: Twenty Fourteen 4.2
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Steps to Reproduce

  1. Disabled Gutenberg editor and ensured Classic Editor was active
  2. Logged in as an Author user (not Admin)
  3. Used a non-block based theme (Twenty Fourteen)
  4. Created new post with title and excerpt containing ampersands: "Hello & Welcome to WordPress"
  5. Saved the post
  6. Examined the saved post

Actual Results

❌ Error condition does NOT occur.
Both the title and excerpt correctly display the ampersand character "&" rather than as "&".

Supplemental Artefacts

https://utfs.io/f/o9kzPXfbC7I8dxA1iqsE7YMe4dTBL2GjorJZ5VXtOI8mASxs

@sabernhardt
15 months ago

title in the editor, before saving the post

@sabernhardt
15 months ago

title shows & in the editor after saving the post

#10 @sabernhardt
15 months ago

The editor's title field had this after I saved a post as an Author-level user:
<input type="text" name="post_title" size="30" value="Hello &amp;amp; welcome after saving" id="title" spellcheck="true" autocomplete="off" />

The front end has &amp; in the markup, which appears as & there.

#11 @kapilpaul
15 months ago

@sabernhardt Thanks for testing it. I believe the &amp; is appearing on the API result as well.

#12 @siliconforks
15 months ago

I'm not sure this is really a bug though? The post title is supposed to be HTML code; this is so you can have titles like Welcome to <i>WordPress</i>. Given that, it makes sense that the ampersand would be stored in the database as an HTML entity (&amp;).

#13 @sabernhardt
15 months ago

This seems related to #11311.

Note: See TracTickets for help on using tickets.