Make WordPress Core

Ticket #11144: wordpress.php.2.patch

File wordpress.php.2.patch, 1.4 KB (added by dwright, 13 years ago)

maintain linefeeds and spaces, only for content:encoded tags, pages or posts WP import

  • wp-admin/import/wordpress.php

     
    5656                preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
    5757                if ( isset($return[1]) ) {
    5858                        $return = preg_replace('|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1]);
    59                         $return = $wpdb->escape( trim( $return ) );
     59                        if ($tag == 'content:encoded') $return = $wpdb->escape( trim( $return, "\t\0\x0B" ) );
     60                        else $return = $wpdb->escape( trim( $return ) );
    6061                } else {
    6162                        $return = '';
    6263                }
     
    9697
    9798                $doing_entry = false;
    9899                $is_wxr_file = false;
     100                $in_content_encoded = false;
    99101
    100102                $fp = $this->fopen($this->file, 'r');
    101103                if ($fp) {
    102104                        while ( !$this->feof($fp) ) {
    103                                 $importline = rtrim($this->fgets($fp));
     105                                $importline = $this->fgets($fp);
    104106
     107                                if ( false !== strpos($importline, '<content:encoded>') ) $in_content_encoded = true;
     108                                if ( false !== strpos($importline, '</content:encoded>') ) $in_content_encoded = false;
     109                                if ( $in_content_encoded ) $importline = rtrim($importline, "\n\r\0\x0B");
     110                                else    $importline = rtrim($importline);
     111
    105112                                // this doesn't check that the file is perfectly valid but will at least confirm that it's not the wrong format altogether
    106113                                if ( !$is_wxr_file && preg_match('|xmlns:wp="http://wordpress[.]org/export/\d+[.]\d+/"|', $importline) )
    107114                                        $is_wxr_file = true;