Make WordPress Core

Ticket #15203: 15203.importer.2.diff

File 15203.importer.2.diff, 865 bytes (added by duck_, 12 years ago)

It needs to work for old exports too

  • parsers.php

     
    465465                global $wpdb;
    466466                preg_match( "|<$tag.*?>(.*?)</$tag>|is", $string, $return );
    467467                if ( isset( $return[1] ) ) {
    468                         $return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] );
     468                        if ( substr( $return[1], 0, 9 ) == '<![CDATA[' ) {
     469                                if ( strpos( $return[1], ']]]]><![CDATA[>' ) !== false ) {
     470                                        preg_match_all( '|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches );
     471                                        $return = '';
     472                                        foreach( $matches[1] as $match )
     473                                                $return .= $match;
     474                                } else {
     475                                        $return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] );
     476                                }
     477                        } else {
     478                                $return = $return[1];
     479                        }
    469480                        $return = $wpdb->escape( trim( $return ) );
    470481                } else {
    471482                        $return = '';