Ticket #4137: 4137-functions.patch

File 4137-functions.patch, 878 bytes (added by pishmishy, 5 years ago)

Patch to fix wp_remote_fopen()s use when allow_url_fopen

  • wp-includes/functions.php

     
    662662} 
    663663 
    664664function wp_remote_fopen( $uri ) { 
    665         $timeout = 10; 
     665        $bytes_limit = 30720;  /* limit on size of source documen bytes, see  
     666                                * Errata for pingback specification. 
     667                                * http://www.hixie.ch/specs/pingback/pingback 
     668                                */ 
     669        $timeout = 10;  
    666670        $parsed_url = @parse_url($uri); 
    667671 
    668672        if ( !$parsed_url || !is_array($parsed_url) ) 
     
    678682 
    679683                //stream_set_timeout($fp, $timeout); // Requires php 4.3 
    680684                $linea = ''; 
    681                 while( $remote_read = fread($fp, 4096) ) 
     685                $bytes = 0; 
     686                while( $remote_read = fread($fp, 4096) && $bytes < $bytes_limit ) 
     687                        $bytes = $bytes + 4096; 
    682688                        $linea .= $remote_read; 
    683689                fclose($fp); 
    684690                return $linea;