WordPress.org

Make WordPress Core

Ticket #2310: https-enclose.diff

File https-enclose.diff, 1.6 KB (added by doit-cu, 12 years ago)

Patch only works with 2.0 release!

  • functions.php

     
    10171017       $punc = '.:?\-';
    10181018       $any = $ltrs . $gunk . $punc;
    10191019
    1020        preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
     1020       preg_match_all("{\b http(s)? : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
    10211021
    10221022       debug_fwrite($log, 'Post contents:');
    10231023       debug_fwrite($log, $content."\n");
     
    10581058       $parts = parse_url( $url );
    10591059       $file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : '');
    10601060       $host = $parts['host'];
     1061
     1062//php prior to 4.3.0 won't support ssl:// in fsockopen.
     1063       if($parts['scheme']=='https' && version_compare(phpversion(), '4.3.0', '<')){
     1064               return false;
     1065       }
     1066
     1067//set our port depending on the scheme we're using.
     1068       if(!isset($parts['port']) && $parts['scheme']=='https'){
     1069               $parts['port'] = 443;
     1070       }
    10611071       if ( !isset( $parts['port'] ) )
    10621072               $parts['port'] = 80;
    10631073
    10641074       $head = "HEAD $file HTTP/1.1\r\nHOST: $host\r\nUser-Agent: WordPress/" . $wp_version . "\r\n\r\n";
    10651075
    1066        $fp = @fsockopen($host, $parts['port'], $err_num, $err_msg, 3);
     1076//we'll need ssl:// in front of the host string to make an https connection
     1077       if($parts['scheme']='https')
     1078               $fp = @fsockopen('ssl://'.$host, $parts['port'], $err_num, $err_msg, 3);
     1079       else
     1080               $fp = @fsockopen($host, $parts['port'], $err_num, $err_msg, 3);
     1081
    10671082       if ( !$fp )
    10681083               return false;
    10691084