Make WordPress Core

#57265 closed enhancement (wontfix)

Strip tags from post title in WP List Table

Reported by: audrasjb's profile audrasjb Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-screenshots has-patch 2nd-opinion close
Focuses: administration Cc:

Description

When post titles are copied or imported from other sources, it's pretty common that HTML tags like strong, em, sup, sub, (etc.) are used.

Currently, those HTML tags are displayed in all WP List Table screens.

It would be nice to strip all HTML tags from being displayed in the post title column of these screens.

Unexpectedly, I couldn't find any existing ticket about this issue, so I opened a new one, but historians are welcome to close this one in favor of any existing ticket :)

This issue was raised by @webaxones in the French WordPress slack team.

Attachments (4)

Capture d’écran 2022-12-02 à 23.41.23.png (212.0 KB) - added by audrasjb 23 months ago.
Screenshot 2022-12-03 at 07.30.35.png (181.9 KB) - added by riccardodicurti 23 months ago.
Capture d’écran 2023-01-16 à 23.04.37.png (232.5 KB) - added by audrasjb 21 months ago.
Before PR3852
Capture d’écran 2023-01-16 à 23.05.13.png (248.9 KB) - added by audrasjb 21 months ago.
After PR3852

Download all attachments as: .zip

Change History (16)

#1 @audrasjb
23 months ago

  • Keywords has-screenshots added

#2 @ironprogrammer
23 months ago

+1 -- I agree that this is odd behavior. Adding another example here, showing how pasting directly from Google Docs can impact the displayed post title.

https://cldup.com/xg1d3ylKh1.gif

#3 @costdev
23 months ago

+1

While we could skip escaping certain formatting HTML tags, truncation would mess this up (<strong>Title and... = page is now bold).

Therefore, stripping the tags as proposed seems the safer option here.

#4 @riccardodicurti
23 months ago

Maybe superscripts and subscripts could be displayed?

<?php
strip_tags($title, ['sup', 'sub']);
?>

#5 @audrasjb
21 months ago

  • Milestone changed from Awaiting Review to 6.2

Yes, I think we can keep sub and superscript.
Moving for 6.2 consideration.

This ticket was mentioned in PR #3852 on WordPress/wordpress-develop by @audrasjb.


21 months ago
#6

  • Keywords has-patch added

Fixes: https://core.trac.wordpress.org/ticket/57265

Please note that this is a first iteration around this change.
Tests and comments welcome :)

#7 @mukesh27
21 months ago

  • Keywords changes-requested added

Thanks @audrasjb for ticket and PR. I also face a similar issue often.

I left one comment on PR. Please have a look.

#8 @ironprogrammer
21 months ago

This looks much cleaner -- thanks, @audrasjb!

Test Report

Patch tested: https://github.com/WordPress/wordpress-develop/pull/3852 (after removal of $allowable_tags) 👍🏻

Environment

  • Hardware: MacBook Pro Apple M1 Pro
  • OS: macOS 12.6.2
  • Browser: Safari 16.2
  • Server: nginx/1.23.3
  • PHP: 7.4.33
  • WordPress: 6.2-alpha-54642-src

Actual Results

  • ✅ Tags are stripped from displayed titles in post list table.

Supplemental Artifacts

Titles tested below include tags typed manually in the post title field (the last three), as well as titles copied from styled text in a Google Doc (the first five).

Before Patch After Patch
https://cldup.com/dt4L1jsEoO.png https://cldup.com/ivFVZuHh6r.png

#9 @audrasjb
21 months ago

  • Keywords 2nd-opinion added; changes-requested removed

Hello there,

I submitted this proposal for more advice in the French WP Slack Team, and I get a bunch of helpful thoughts, which can be summarized as follows:

If we strip tags from title, we would lose the information that a title contains HTML tags, which can be useful for debugging unwanted tags (after an import, or after a bad copy-paste for example).

Even on the accessibility side of the topic, while one could say that it's not a great experience for assistive technology users to have these tags fully spelled out, it might be helpful to know that a title contains HTML tags.

Thanks to @chaton666, @petitphp, @webaxones, @maigret, @nicomollet for sharing their thoughts :)

#10 @bozzmedia
21 months ago

We are having a bit of a related discussion here:
https://github.com/WordPress/gutenberg/issues/38637

Stripping the tags out of the list table but not the actual titles will further obscure this issue where markup is included in the post title but is not editable.

If we must support markup in the post title there needs to be some kind of code/text view to edit the full contents of the post title. Right now the only work around is to cut and paste into external editors, and the list view is one of the only places you can actually discover this issue.

#11 @audrasjb
21 months ago

  • Keywords close added

Adding close keyword, pending further comments.

#12 @audrasjb
21 months ago

  • Milestone 6.2 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

As per previous comments, closing this ticket as wontfix.
Feel free to reopen it if needed :)

Note: See TracTickets for help on using tickets.