From d10c22bc8966176a52ac0ed05417999ec2b30b6c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 12 Mar 2019 22:32:54 +0000 Subject: [PATCH] Comments: Improve comment content filtering. Merges [44842] to the 5.0 branch. git-svn-id: https://develop.svn.wordpress.org/branches/5.0@44844 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/ajax-actions.php | 2 ++ src/wp-includes/comment.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 2e14996078..dd95155e76 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -1070,6 +1070,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/src/wp-includes/comment.php b/src/wp-includes/comment.php index 97685711bf..374467f8bf 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -3098,6 +3098,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 {