WordPress.org

Make WordPress Core

Ticket #10372: wp-app.patch

File wp-app.patch, 1.1 KB (added by mysz, 6 years ago)

wp-app.php patch

  • wp-app.php

     
    785785        if(!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext'])) 
    786786            $this->internal_error(__('Error ocurred while accessing post metadata for file location.')); 
    787787 
    788         status_header('200'); 
    789         header('Content-Type: ' . $entry['post_mime_type']); 
    790         header('Connection: close'); 
     788        $location = get_option ('upload_path') . '/' . $location; 
     789        if ($fp = fopen($location, "rb")) { 
     790            status_header('200'); 
     791            header('Content-Type: ' . $entry['post_mime_type']); 
     792            header('Connection: close'); 
    791793 
    792         $fp = fopen($location, "rb"); 
    793         while(!feof($fp)) { 
    794             echo fread($fp, 4096); 
    795         } 
    796         fclose($fp); 
     794            while(!feof($fp)) { 
     795                echo fread($fp, 4096); 
     796            } 
     797            fclose($fp); 
     798        } 
     799        else { 
     800            status_header ('404'); 
     801        } 
    797802 
    798803        log_app('function',"get_file($postID)"); 
    799804        exit;