Use prepare() for the duplicate comment query in wp_allow_comment().
see #21767 git-svn-id: http://core.svn.wordpress.org/trunk@23973 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6907174995
commit
375cb66409
|
@ -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') )
|
||||
|
|
Loading…
Reference in New Issue