Ticket #4579: 4579.liberal.diff

File 4579.liberal.diff, 1.2 KB (added by ruckus, 4 years ago)

Liberal filtering that just protects the database and is more future proof

  • wp-includes/comment.php

     
    552552        extract($commentdata, EXTR_SKIP); 
    553553 
    554554        if ( ! isset($comment_author_IP) ) 
    555                 $comment_author_IP = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] ); 
     555                $comment_author_IP = $wpdb->escape($_SERVER['REMOTE_ADDR']); 
    556556        if ( ! isset($comment_date) ) 
    557557                $comment_date = current_time('mysql'); 
    558558        if ( ! isset($comment_date_gmt) ) 
     
    645645 * @return int The ID of the comment after adding. 
    646646 */ 
    647647function wp_new_comment( $commentdata ) { 
     648        global $wpdb; 
     649 
    648650        $commentdata = apply_filters('preprocess_comment', $commentdata); 
    649651 
    650652        $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; 
    651653        $commentdata['user_ID']         = (int) $commentdata['user_ID']; 
    652654 
    653         $commentdata['comment_author_IP'] = preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] ); 
     655        $commentdata['comment_author_IP'] = $wpdb->escape($_SERVER['REMOTE_ADDR']); 
    654656        $commentdata['comment_agent']     = $_SERVER['HTTP_USER_AGENT']; 
    655657 
    656658        $commentdata['comment_date']     = current_time('mysql');