WordPress.org

Make WordPress Core

Ticket #4452: import-cdata-r5694.patch

File import-cdata-r5694.patch, 2.6 KB (added by tellyworth, 7 years ago)
  • wp-admin/import/wordpress.php

     
    3737        function get_tag( $string, $tag ) { 
    3838                global $wpdb; 
    3939                preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return); 
    40                 $return = $wpdb->escape( trim( $return[1] ) ); 
     40                $return = preg_replace('|<!\[CDATA\[(.*)\]\]>|', '$1', $return[1]); 
     41                $return = $wpdb->escape( trim( $return ) ); 
    4142                return $return; 
    4243        } 
    4344 
     
    215216                $cat_names = (array) $wpdb->get_col("SELECT cat_name FROM $wpdb->categories"); 
    216217 
    217218                while ( $c = array_shift($this->categories) ) { 
    218                         $cat_name = trim(str_replace(array ('<![CDATA[', ']]>'), '', $this->get_tag( $c, 'wp:cat_name' ))); 
     219                        $cat_name = trim($this->get_tag( $c, 'wp:cat_name' )); 
    219220 
    220221                        // If the category exists we leave it alone 
    221222                        if ( in_array($cat_name, $cat_names) ) 
     
    274275                $post_author    = $this->get_tag( $post, 'dc:creator' ); 
    275276 
    276277                $post_content = $this->get_tag( $post, 'content:encoded' ); 
    277                 $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content); 
    278278                $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 
    279279                $post_content = str_replace('<br>', '<br />', $post_content); 
    280280                $post_content = str_replace('<hr>', '<hr />', $post_content); 
  • wp-admin/export.php

     
    131131        This is a WordPress eXtended RSS file generated by WordPress as an export of  
    132132        your blog. It contains information about your blog's posts, comments, and  
    133133        categories. You may use this file to transfer that content from one site to  
    134         another. This file is not intended to serve as a complete backup of your  
     134        another. This file is not intended to serve as a complete backup of your 
    135135        blog. 
    136136         
    137137        To import this information into a WordPress blog follow these steps: 
     
    203203if ( $comments ) { foreach ( $comments as $c ) { ?> 
    204204<wp:comment> 
    205205<wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id> 
    206 <wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author> 
     206<wp:comment_author><?php echo wxr_cdata($c->comment_author); ?></wp:comment_author> 
    207207<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email> 
    208208<wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url> 
    209209<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>