WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 12 months ago

#31156 closed defect (bug) (duplicate)

TinyMCE doesn't always clean up and remove the non-breaking spaces it's creating

Reported by: Denis-de-Bernardy Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1
Component: TinyMCE Keywords:
Focuses: Cc:

Description

TinyMCE occasionally creates two or more invisible non-breaking spaces (encoding 0xA0 or, in my case on OS X Yosemite using Safari 8.0.2, 0xC2A0), but then doesn't clean them up properly.

The rational for inserting them at all seems sane. For instance, the 0xC2A0 0xC2A0 character sequence appears when you inadvertently type space twice as you type. If you delete one of the two spaces, they get replaced to a single space as needed.

A problem occurs, however, when you copy and paste, placing the cursor between two unbreaking space characters and hitting space will yield unexpected results and incorrectly keep the character around.

TinyMCE content: foo  bar baz

> select replace(post_content, char(0xC2), ' ') from wp_posts where id = 11;
+----------------------------------------+
| replace(post_content, char(0xC2), ' ') |
+----------------------------------------+
| foo ? ?bar baz            |
+----------------------------------------+
1 row in set (0.00 sec)

Select bar and *one* of the spaces before it, and paste the string test.

TinyMCE content: foo test baz

MariaDB [mesoconcepts]> select replace(post_content, char(0xC2), ' ') from wp_posts where id = 11;
+----------------------------------------+
| replace(post_content, char(0xC2), ' ') |
+----------------------------------------+
| foo test ?baz            |
+----------------------------------------+
1 row in set (0.00 sec)

It seems like an old unreported bug, too. See for instance this reply that references the problem 8 years ago.

I imagine my own site isn't the only one with non-breaking space clutter around. In addition to reporting the bug upstream to MoxieCode (I you've the relevant contacts to do so), I'd like to suggest that we actually try to salvage polluted posts during the next upgrade.

Change History (5)

This ticket was mentioned in Slack in #meta by sergeybiryukov. View the logs.


5 years ago

This ticket was mentioned in Slack in #core by iseulde. View the logs.


5 years ago

This ticket was mentioned in Slack in #core-editor by iseulde. View the logs.


4 years ago

#5 @azaozz
12 months ago

  • Resolution set to duplicate
  • Status changed from new to closed

Looking again, this is a duplicate of #31157 and #26842. It is the browsers way to keep multiple spaces as typed by the users, but also to "guess" user intent while typing in contenteditable.

Note: See TracTickets for help on using tickets.