WordPress.org

Make WordPress Core

Changeset 36597


Ignore:
Timestamp:
02/20/2016 07:55:03 PM (4 years ago)
Author:
azaozz
Message:

TinyMCE: fix the regex that removes spaces from empty paragraphs. Was causing problems when wpautop is disabled and there are many U+00A0 chars between the opening <p> and an inline tag. These chars are inserted by the browsers to maintain consecutive spaces typed by the users in contentEditable.

Fixes #35890.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

    r36384 r36597  
    118118
    119119            // Remove spaces from empty paragraphs.
    120             event.content = event.content.replace( /<p>(?:&nbsp;|\u00a0|\uFEFF|\s)+<\/p>/gi, '<p><br /></p>' );
     120            // Avoid backtracking, can freeze the editor. See #35890.
     121            // (This is also quite faster than using only one regex.)
     122            event.content = event.content.replace( /<p>([^<>]+)<\/p>/gi, function( tag, text ) {
     123                if ( /^(&nbsp;|\s|\u00a0|\ufeff)+$/i.test( text ) ) {
     124                    return '<p><br /></p>';
     125                }
     126
     127                return tag;
     128            });
    121129        }
    122130    });
Note: See TracChangeset for help on using the changeset viewer.