WordPress.org

Make WordPress Core

Changeset 985 in tests


Ignore:
Timestamp:
08/21/2012 11:29:16 AM (6 years ago)
Author:
nbachiyski
Message:

Add slashes to the data passed to wp_*_comment()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/factory.php

    r962 r985  
    7777
    7878    function create_object( $args ) {
    79         return wp_insert_comment( $args );
     79        return wp_insert_comment( $this->addslashes_deep( $args ) );
    8080    }
    8181
    8282    function update_object( $comment_id, $fields ) {
    8383        $fields['comment_ID'] = $comment_id;
    84         return wp_update_comment( $fields );
     84        return wp_update_comment( $this->addslashes_deep( $fields ) );
    8585    }
    8686
     
    248248        return new WP_UnitTest_Factory_Callback_After_Create( $function );
    249249    }
     250
     251    function addslashes_deep($value) {
     252        if ( is_array( $value ) ) {
     253            $value = array_map( array( $this, 'addslashes_deep' ), $value );
     254        } elseif ( is_object( $value ) ) {
     255            $vars = get_object_vars( $value );
     256            foreach ($vars as $key=>$data) {
     257                $value->{$key} = $this->addslashes_deep( $data );
     258            }
     259        } elseif ( is_string( $value ) ) {
     260            $value = addslashes( $value );
     261        }
     262
     263        return $value;
     264    }
     265
    250266}
    251267
Note: See TracChangeset for help on using the changeset viewer.