WordPress.org

Make WordPress Core

Ticket #11574: 11574-improved.diff

File 11574-improved.diff, 886 bytes (added by westi, 11 years ago)

Better patch which merges the two regexs and preserves the old non-greed behaviour

  • wordpress/wp-admin/import/wordpress.php

    ### Eclipse Workspace Patch 1.0
    #P wordpress-tests
     
    5959
    6060        function get_tag( $string, $tag ) {
    6161                global $wpdb;
    62                 preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
    63                 if ( isset($return[1]) ) {
    64                         $return = preg_replace('|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1]);
    65                         $return = $wpdb->escape( trim( $return ) );
     62                preg_match("@(<$tag.*?><!\[CDATA\[(.*?)\]\]></$tag>|<$tag.*?>(.*?)</$tag>)@is", $string, $return);
     63                if ( !empty($return[2]) ) {
     64                        $return = $wpdb->escape( trim( $return[2] ) );
     65                } else if ( !empty($return[3]) ) {
     66                        $return = $wpdb->escape( trim( $return[3] ) );
    6667                } else {
    6768                        $return = '';
    6869                }