From 758d91f1280500b8633bc2ccc6317dbd734a7657 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 1 Nov 2005 22:26:11 +0000 Subject: [PATCH] Check for error response codes, don't proxy via localhost in command line mode --- includes/HttpFunctions.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 19cd63e12f..c0df2e92d4 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -28,6 +28,11 @@ function wfGetHTTP( $url, $timeout = 'default' ) { curl_exec( $c ); $text = ob_get_contents(); ob_end_clean(); + + # Don't return the text of error messages, return false on error + if ( curl_getinfo( $c, CURLINFO_HTTP_CODE ) != 200 ) { + $text = false; + } curl_close( $c ); } else { # Otherwise use file_get_contents, or its compatibility function from GlobalFunctions.php @@ -43,7 +48,11 @@ function wfGetHTTP( $url, $timeout = 'default' ) { * Check if the URL can be served by localhost */ function wfIsLocalURL( $url ) { - global $wgConf; + global $wgCommandLineMode, $wgConf; + if ( $wgCommandLineMode ) { + return false; + } + // Extract host part if ( preg_match( '!^http://([\w.-]+)[/:].*$!', $url, $matches ) ) { $host = $matches[1]; -- 2.20.1