From c3e471a535bc8d4772e0d6c70576af47ecd84ced Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 12 Apr 2013 13:25:16 +0000 Subject: [PATCH] Use prepare() for the duplicate comment query in wp_allow_comment(). see #21767 git-svn-id: https://develop.svn.wordpress.org/trunk@23973 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/comment.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index e1c3509b47..b452856248 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -671,10 +671,10 @@ function wp_allow_comment($commentdata) { // Simple duplicate check // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) - $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_parent = '$comment_parent' AND comment_approved != 'trash' AND ( comment_author = '$comment_author' "; + $dupe = $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", wp_unslash( $comment_post_ID ), wp_unslash( $comment_parent ), wp_unslash( $comment_author ) ); if ( $comment_author_email ) - $dupe .= "OR comment_author_email = '$comment_author_email' "; - $dupe .= ") AND comment_content = '$comment_content' LIMIT 1"; + $dupe .= $wpdb->prepare( "OR comment_author_email = %s ", wp_unslash( $comment_author_email ) ); + $dupe .= $wpdb->prepare( ") AND comment_content = %s LIMIT 1", wp_unslash( $comment_content ) ); if ( $wpdb->get_var($dupe) ) { do_action( 'comment_duplicate_trigger', $commentdata ); if ( defined('DOING_AJAX') )