Show
Ignore:
Timestamp:
09/03/08 18:34:20 (3 months ago)
Author:
ryan
Message:

WXR Importer fix to resolve absolute urls without protocol and domain. fixes #7595

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/import/wordpress.php

    r8645 r8799  
    106106                if ( !$is_wxr_file && preg_match('|xmlns:wp="http://wordpress[.]org/export/\d+[.]\d+/"|', $importline) ) 
    107107                    $is_wxr_file = true; 
    108  
     108                 
     109                if ( false !== strpos($importline, '<wp:base_site_url>') ) { 
     110                    preg_match('|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url); 
     111                    $this->base_url = $url[1]; 
     112                    continue; 
     113                } 
    109114                if ( false !== strpos($importline, '<wp:category>') ) { 
    110115                    preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); 
     
    540545        if ($this->fetch_attachments and $remote_url) { 
    541546            printf( __('Importing attachment <em>%s</em>... '), htmlspecialchars($remote_url) ); 
     547             
     548            // If the URL is absolute, but does not contain http, upload it assuming the base_site_url variable 
     549            if ( preg_match('/^\/[\w\W]+$/', $remote_url) ) 
     550                $remote_url = rtrim($this->base_url,'/').$remote_url; 
     551             
    542552            $upload = $this->fetch_remote_file($postdata, $remote_url); 
    543553            if ( is_wp_error($upload) ) {