diff --git a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js index 13ef3af059..7a811404cd 100644 --- a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js @@ -117,7 +117,15 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } // Remove spaces from empty paragraphs. - event.content = event.content.replace( /

(?: |\u00a0|\uFEFF|\s)+<\/p>/gi, '


' ); + // Avoid backtracking, can freeze the editor. See #35890. + // (This is also quite faster than using only one regex.) + event.content = event.content.replace( /

([^<>]+)<\/p>/gi, function( tag, text ) { + if ( /^( |\s|\u00a0|\ufeff)+$/i.test( text ) ) { + return '


'; + } + + return tag; + }); } });