Reverting r91642 per CR and pending review need-patch/patch in bug 29755
authorKrinkle <krinkle@users.mediawiki.org>
Fri, 8 Jul 2011 17:45:26 +0000 (17:45 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Fri, 8 Jul 2011 17:45:26 +0000 (17:45 +0000)
includes/HttpFunctions.php

index c73d9a9..bac062f 100644 (file)
@@ -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
         */