From c5963b8760f02e859bcdeb0fd7b91c86341b4406 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 17 Sep 2015 22:21:06 +0000 Subject: [PATCH] In `wp-comments-post.php`, sanity check a few of the comment inputs that are expected to be a string beford calling string-only functions on them. Props Kloon. Fixes #23416. git-svn-id: https://develop.svn.wordpress.org/trunk@34274 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-comments-post.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-comments-post.php b/src/wp-comments-post.php index 44eab61d1c..cb7bd50fa4 100644 --- a/src/wp-comments-post.php +++ b/src/wp-comments-post.php @@ -89,10 +89,10 @@ if ( ! comments_open( $comment_post_ID ) ) { do_action( 'pre_comment_on_post', $comment_post_ID ); } -$comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null; -$comment_author_email = ( isset($_POST['email']) ) ? trim($_POST['email']) : null; -$comment_author_url = ( isset($_POST['url']) ) ? trim($_POST['url']) : null; -$comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null; +$comment_author = ( isset( $_POST['author'] ) && is_string( $_POST['author'] ) ) ? trim( strip_tags( $_POST['author'] ) ) : null; +$comment_author_email = ( isset( $_POST['email'] ) && is_email( $_POST['email'] ) ) ? trim( $_POST['email'] ) : null; +$comment_author_url = ( isset( $_POST['url'] ) && is_string( $_POST['url'] ) ) ? trim( $_POST['url'] ) : null; +$comment_content = ( isset( $_POST['comment'] ) && is_string( $_POST['comment'] ) ) ? trim( $_POST['comment'] ) : null; // If the user is logged in $user = wp_get_current_user();