r91738 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91737‎ | r91738 | r91739 >
Date:17:45, 8 July 2011
Author:krinkle
Status:ok
Tags:
Comment:
Reverting r91642 per CR and pending review need-patch/patch in bug 29755
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HttpFunctions.php
@@ -273,61 +273,12 @@
274274 $this->proxy = 'http://localhost:80/';
275275 } elseif ( $wgHTTPProxy ) {
276276 $this->proxy = $wgHTTPProxy ;
277 - } elseif ( $this->useProxy( $this->url ) ) {
278 - $this->proxy = $this->useProxy( $this->url );
 277+ } elseif ( getenv( "http_proxy" ) ) {
 278+ $this->proxy = getenv( "http_proxy" );
279279 }
280280 }
281281
282282 /**
283 - * Determine HTTP proxy from environment settings respecting
284 - * 'http_proxy' and 'no_proxy' environment variables
285 - */
286 - public static function useProxy( $url ) {
287 - if ( $proxy = getenv( "http_proxy" ) ) {
288 - $useproxy = true;
289 - if ( $url && ( $noproxy = preg_split( "#\s*,\s*#is", getenv( "no_proxy" ) ) ) ) {
290 - foreach ( $noproxy as $n ) {
291 - if ( preg_match('#(\d+)\.(\d+)\.(\d+)\.(\d+)/(\d+)#s', $n, $m) &&
292 - preg_match('#^[a-z0-9_]+://(?:[^/]*:[^/]*@)?([^/@]+)(?:/|$|\?)#is', $url, $ip) ) {
293 - $mask = array(
294 - max( 0x100 - ( 1 << max( 8-$m[5], 0 ) ), 0 ),
295 - max( 0x100 - ( 1 << max( 16-$m[5], 0 ) ), 0 ),
296 - max( 0x100 - ( 1 << max( 24-$m[5], 0 ) ), 0 ),
297 - max( 0x100 - ( 1 << max( 32-$m[5], 0 ) ), 0 ),
298 - );
299 - $ip = @gethostbyname( $ip[1] );
300 - if ( preg_match( '#(\d+)\.(\d+)\.(\d+)\.(\d+)#s', $ip, $ipm ) &&
301 - ( intval( $ipm[1] ) & $mask[0] ) == intval( $m[1] ) &&
302 - ( intval( $ipm[2] ) & $mask[1] ) == intval( $m[2] ) &&
303 - ( intval( $ipm[3] ) & $mask[2] ) == intval( $m[3] ) &&
304 - ( intval( $ipm[4] ) & $mask[3] ) == intval( $m[4] ) ) {
305 - $useproxy = false;
306 - break;
307 - }
308 - } else {
309 - $n = preg_replace( '/#.*$/is', '', $n );
310 - $n = preg_quote( $n );
311 - $n = str_replace( '\\*', '.*', $n );
312 - if ( preg_match( '#'.$n.'#is', $url ) ) {
313 - $useproxy = false;
314 - break;
315 - }
316 - }
317 - }
318 - }
319 - if ( $useproxy ) {
320 - $proxy = preg_replace( '#^http://#is', '', $proxy );
321 - $proxy = preg_replace( '#/*$#is', '', $proxy );
322 - }
323 - else {
324 - $proxy = null;
325 - }
326 - return $proxy;
327 - }
328 - return null;
329 - }
330 -
331 - /**
332283 * Set the refererer header
333284 */
334285 public function setReferer( $url ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91642Bug #29755: Apply patch from Vitaliy Filippov so that MW's HTTP client...mah14:56, 7 July 2011

Status & tagging log