Make WordPress Core

Ticket #21007: importer.diff

File importer.diff, 1.5 KB (added by SeMeKh, 11 years ago)

Patch to fix the omitted-backslashes bug

  • wordpress-importer.php

     
    596596
    597597                                        $comment_post_ID = $post_id = $this->process_attachment( $postdata, $remote_url );
    598598                                } else {
    599                                         $comment_post_ID = $post_id = wp_insert_post( $postdata, true );
     599                                        $comment_post_ID = $post_id = wp_insert_post( $this->addslashes_deep( $postdata ), true );
     600//                                      $comment_post_ID = $post_id = wp_insert_post( $postdata, true );
    600601                                }
    601602
    602603                                if ( is_wp_error( $post_id ) ) {
     
    10811082        function cmpr_strlen( $a, $b ) {
    10821083                return strlen($b) - strlen($a);
    10831084        }
     1085
     1086        /**
     1087         * Navigates through an array and add slashes to escape the values.
     1088         *
     1089         * If an array is passed, the array_map() function causes a callback to pass the
     1090         * value back to the function. This value will be slash-escaped.
     1091         *
     1092         * @param array|string $value The array or string to be escaped
     1093         * @return array|string Escaped array (or string in the callback).
     1094         */
     1095        function addslashes_deep($value) {
     1096                if ( is_array($value) ) {
     1097                        $value = array_map(array(&$this, 'addslashes_deep'), $value);
     1098                } elseif ( is_object($value) ) {
     1099                        $vars = get_object_vars( $value );
     1100                        foreach ($vars as $key=>$data) {
     1101                                $value->{$key} = addslashes_deep( $data );
     1102                        }
     1103                } else {
     1104                        $value = addslashes($value);
     1105                }
     1106
     1107                return $value;
     1108        }
    10841109}
    10851110
    10861111} // class_exists( 'WP_Importer' )