[wp-trac] [WordPress Trac] #26842: Contenteditable, multiple spaces,  , and U+00A0
WordPress Trac
noreply at wordpress.org
Tue Jan 30 00:31:32 UTC 2018
#26842: Contenteditable, multiple spaces,  , and U+00A0
------------------------------+-----------------------------
Reporter: azaozz | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: TinyMCE | Version: 4.7
Severity: normal | Resolution:
Keywords: needs-unit-tests | Focuses:
------------------------------+-----------------------------
Comment (by CK MacLeod):
I wonder where the double quote problem came in - didn't come up in my
experiments.
I ended up with a hybrid approach for my own site, as the post I linked
above indicates.
Replying to [comment:25 y0uri]:
> Replying to [comment:23 CK MacLeod]:
> > The following function works, but, like most of the other fixes
proposed on other threads, or that you can find around the Web - some
focusing on WP php functions, some on tinyMCE or other Javascript methods
- it doesn't allow users who want non-breaking spaces to keep them:
> >
> > {{{
> > add_filter( 'content_save_pre', 'remove_buggy_nbsps', 99 );
> >
> > function remove_buggy_nbsps( $content ) {
> >
> > return str_replace( '\xc2\xa0', ' ', $content);
> >
> > }
> > }}}
> >
> > It could be improved upon in various ways, no doubt, but, like I said,
it works.
>
> It only works if you replace these single quotes by double quotes, ie.:
> {{{
> return str_replace( "\xc2\xa0", ' ', $content);
> }}}
>
> Thanks for this fix btw. The nbsp's were messing things up in another
system that depends on a WP feed, when editing there would sometimes
appear nbsp's in the content, instead of regular spaces as were there
before. And only when editing in Webkit-based browsers. Your filter
function solves this problem.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26842#comment:27>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list