From 9f67a915d99fc82be9903e82bd5e5765760d5403 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 11 Nov 2016 23:06:03 +0000 Subject: [PATCH] TinyMCE: fix freezing the editor when wpautop is disabled and a paragraph starts with a lot of white space characters. Fixes #38294. git-svn-id: https://develop.svn.wordpress.org/trunk@39204 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/tinymce/plugins/wordpress/plugin.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js index 8209ba4109..17bda8861a 100644 --- a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js @@ -131,10 +131,9 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } // Remove spaces from empty paragraphs. - // Avoid backtracking, can freeze the editor. See #35890. - // (This is also quite faster than using only one regex.) + // Try to avoid a lot of backtracking, can freeze the editor. See #35890 and #38294. event.content = event.content.replace( /

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


'; }