Merge "Added new MWTimestamp::getRelativeTimestamp for pure relative."
[lhc/web/wiklou.git] / includes / WebRequest.php
index 80881c9..23eee04 100644 (file)
@@ -881,8 +881,9 @@ class WebRequest {
                        return;
                }
 
-               if ( function_exists( 'apache_request_headers' ) ) {
-                       foreach ( apache_request_headers() as $tempName => $tempValue ) {
+               $apacheHeaders = function_exists( 'apache_request_headers' ) ? apache_request_headers() : false;
+               if ( $apacheHeaders ) {
+                       foreach ( $apacheHeaders as $tempName => $tempValue ) {
                                $this->headers[strtoupper( $tempName )] = $tempValue;
                        }
                } else {
@@ -1141,7 +1142,7 @@ HTML;
                        # unless the address is not sensible (e.g. private). However, prefer private
                        # IP addresses over proxy servers controlled by this site (more sensible).
                        foreach ( $ipchain as $i => $curIP ) {
-                               $curIP = IP::canonicalize( $curIP );
+                               $curIP = IP::sanitizeIP( IP::canonicalize( $curIP ) );
                                if ( wfIsTrustedProxy( $curIP ) && isset( $ipchain[$i + 1] ) ) {
                                        if ( wfIsConfiguredProxy( $curIP ) || // bug 48919
                                                ( IP::isPublic( $ipchain[$i + 1] ) || $wgUsePrivateIPs )