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.
Built from https://develop.svn.wordpress.org/trunk@36597


git-svn-id: http://core.svn.wordpress.org/trunk@36564 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2016-02-20 19:56:27 +00:00
parent 24cfa6a40a
commit acb6cb1d74
4 changed files with 11 additions and 3 deletions

View File

@ -117,7 +117,15 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
}
// Remove spaces from empty paragraphs.
event.content = event.content.replace( /<p>(?:&nbsp;|\u00a0|\uFEFF|\s)+<\/p>/gi, '<p><br /></p>' );
// Avoid backtracking, can freeze the editor. See #35890.
// (This is also quite faster than using only one regex.)
event.content = event.content.replace( /<p>([^<>]+)<\/p>/gi, function( tag, text ) {
if ( /^(&nbsp;|\s|\u00a0|\ufeff)+$/i.test( text ) ) {
return '<p><br /></p>';
}
return tag;
});
}
});

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-36596';
$wp_version = '4.5-alpha-36597';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.