From 698faf3b174dc11a120b6e9a2c04cafa77adf170 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 13 Jul 2015 03:18:47 +0000 Subject: [PATCH] TinyMCE: - Go back to encoding the editor content only when TinyMCE is used. - Add check and encode `` if present. See #32425. git-svn-id: https://develop.svn.wordpress.org/trunk@33187 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-editor.php | 9 +++++++++ src/wp-includes/default-filters.php | 3 --- src/wp-includes/formatting.php | 5 +---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index 0ed7747a64..fd2f007686 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -251,6 +251,11 @@ final class _WP_Editors { '%s' ); + // Prepare the content for the Visual or Text editor + if ( self::$this_tinymce ) { + add_filter( 'the_editor_content', 'format_for_editor', 10, 2 ); + } + /** * Filter the default editor content. * @@ -270,6 +275,10 @@ final class _WP_Editors { $content = apply_filters( 'richedit_pre', $content ); } + if ( false !== stripos( $content, 'textarea' ) ) { + $content = preg_replace( '%\n\n"; diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index b1f69ea98c..07f449f2f3 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -203,9 +203,6 @@ add_filter( 'title_save_pre', 'trim' ); add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 ); -// Prepare the content for the Visual or Text editor -add_filter( 'the_editor_content', 'format_for_editor', 10, 2 ); - // Actions add_action( 'wp_head', '_wp_render_title_tag', 1 ); add_action( 'wp_head', 'wp_enqueue_scripts', 1 ); diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index b4ea8bd0fc..cdb9a345c2 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -3087,10 +3087,7 @@ function ent2ncr( $text ) { * @return string The formatted text after filter is applied. */ function format_for_editor( $text, $default_editor = null ) { - // Back-compat: check if any characters need encoding. - if ( ! empty( $text ) && ( false !== strpos( $text, '<' ) || false !== strpos( $text, '>' ) || - preg_match( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', $text ) ) ) { - + if ( $text ) { $text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) ); }