From 1ff333ca3bc3eed743bebbcfb44aa7280020a7cc Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 12 Mar 2019 22:37:22 +0000 Subject: [PATCH] Comments: Improve comment content filtering. Merges [44842] to the 4.6 branch. Built from https://develop.svn.wordpress.org/branches/4.6@44848 git-svn-id: http://core.svn.wordpress.org/branches/4.6@44680 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 2 ++ wp-includes/comment.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index d896f200b4..21247d829e 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -1025,6 +1025,8 @@ function wp_ajax_replyto_comment( $action ) { if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { kses_remove_filters(); // start with a clean slate kses_init_filters(); // set up the filters + remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); + add_filter( 'pre_comment_content', 'wp_filter_kses' ); } } } else { diff --git a/wp-includes/comment.php b/wp-includes/comment.php index dad3f7639a..871351f47e 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -2872,6 +2872,8 @@ function wp_handle_comment_submission( $comment_data ) { ) { kses_remove_filters(); // start with a clean slate kses_init_filters(); // set up the filters + remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); + add_filter( 'pre_comment_content', 'wp_filter_kses' ); } } } else {