From 0e22bbc8830b3c5bdab342fa98455921fdb97a6a Mon Sep 17 00:00:00 2001 From: Krinkle Date: Fri, 8 Jul 2011 17:45:26 +0000 Subject: [PATCH] Reverting r91642 per CR and pending review need-patch/patch in bug 29755 --- includes/HttpFunctions.php | 53 ++------------------------------------ 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index c73d9a94ba..bac062fd5c 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -273,60 +273,11 @@ class MWHttpRequest { $this->proxy = 'http://localhost:80/'; } elseif ( $wgHTTPProxy ) { $this->proxy = $wgHTTPProxy ; - } elseif ( $this->useProxy( $this->url ) ) { - $this->proxy = $this->useProxy( $this->url ); + } elseif ( getenv( "http_proxy" ) ) { + $this->proxy = getenv( "http_proxy" ); } } - /** - * Determine HTTP proxy from environment settings respecting - * 'http_proxy' and 'no_proxy' environment variables - */ - public static function useProxy( $url ) { - if ( $proxy = getenv( "http_proxy" ) ) { - $useproxy = true; - if ( $url && ( $noproxy = preg_split( "#\s*,\s*#is", getenv( "no_proxy" ) ) ) ) { - foreach ( $noproxy as $n ) { - if ( preg_match('#(\d+)\.(\d+)\.(\d+)\.(\d+)/(\d+)#s', $n, $m) && - preg_match('#^[a-z0-9_]+://(?:[^/]*:[^/]*@)?([^/@]+)(?:/|$|\?)#is', $url, $ip) ) { - $mask = array( - max( 0x100 - ( 1 << max( 8-$m[5], 0 ) ), 0 ), - max( 0x100 - ( 1 << max( 16-$m[5], 0 ) ), 0 ), - max( 0x100 - ( 1 << max( 24-$m[5], 0 ) ), 0 ), - max( 0x100 - ( 1 << max( 32-$m[5], 0 ) ), 0 ), - ); - $ip = @gethostbyname( $ip[1] ); - if ( preg_match( '#(\d+)\.(\d+)\.(\d+)\.(\d+)#s', $ip, $ipm ) && - ( intval( $ipm[1] ) & $mask[0] ) == intval( $m[1] ) && - ( intval( $ipm[2] ) & $mask[1] ) == intval( $m[2] ) && - ( intval( $ipm[3] ) & $mask[2] ) == intval( $m[3] ) && - ( intval( $ipm[4] ) & $mask[3] ) == intval( $m[4] ) ) { - $useproxy = false; - break; - } - } else { - $n = preg_replace( '/#.*$/is', '', $n ); - $n = preg_quote( $n ); - $n = str_replace( '\\*', '.*', $n ); - if ( preg_match( '#'.$n.'#is', $url ) ) { - $useproxy = false; - break; - } - } - } - } - if ( $useproxy ) { - $proxy = preg_replace( '#^http://#is', '', $proxy ); - $proxy = preg_replace( '#/*$#is', '', $proxy ); - } - else { - $proxy = null; - } - return $proxy; - } - return null; - } - /** * Set the refererer header */ -- 2.20.1