WebRequest::getRequestURL: Follow up Ibe00a6b8
[lhc/web/wiklou.git] / includes / WebRequest.php
index 9b6d9ce..3bdf645 100644 (file)
@@ -224,7 +224,7 @@ class WebRequest {
                }
 
                $matches = self::getPathInfo( 'title' );
-               foreach( $matches as $key => $val) {
+               foreach( $matches as $key => $val ) {
                        $this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val;
                }
        }
@@ -603,7 +603,7 @@ class WebRequest {
         * @return Boolean
         */
        public function checkSessionCookie() {
-               return isset( $_COOKIE[ session_name() ] );
+               return isset( $_COOKIE[session_name()] );
        }
 
        /**
@@ -654,11 +654,13 @@ class WebRequest {
                if( $hash !== false ) {
                        $base = substr( $base, 0, $hash );
                }
+
                if( $base[0] == '/' ) {
-                       return $base;
+                       // More than one slash will look like it is protocol relative
+                       return preg_replace( '!^/+!', '/', $base );
                } else {
                        // We may get paths with a host prepended; strip it.
-                       return preg_replace( '!^[^:]+://[^/]+/!', '/', $base );
+                       return preg_replace( '!^[^:]+://[^/]+/+!', '/', $base );
                }
        }
 
@@ -844,7 +846,7 @@ class WebRequest {
 
                if ( function_exists( 'apache_request_headers' ) ) {
                        foreach ( apache_request_headers() as $tempName => $tempValue ) {
-                               $this->headers[ strtoupper( $tempName ) ] = $tempValue;
+                               $this->headers[strtoupper( $tempName )] = $tempValue;
                        }
                } else {
                        foreach ( $_SERVER as $name => $value ) {
@@ -1103,7 +1105,7 @@ HTML;
                                $curIP = IP::canonicalize( $curIP );
                                if ( wfIsTrustedProxy( $curIP ) ) {
                                        if ( isset( $ipchain[$i + 1] ) ) {
-                                               if ( $wgUsePrivateIPs || IP::isPublic( $ipchain[$i + 1 ] ) ) {
+                                               if ( $wgUsePrivateIPs || IP::isPublic( $ipchain[$i + 1] ) ) {
                                                        $ip = $ipchain[$i + 1];
                                                }
                                        }
@@ -1133,21 +1135,6 @@ HTML;
        public function setIP( $ip ) {
                $this->ip = $ip;
        }
-
-       /**
-        * Export the resolved user IP, HTTP headers, and session ID.
-        * The result will be reasonably sized to allow for serialization.
-        *
-        * @return Array
-        * @since 1.21
-        */
-       public function exportUserSession() {
-               return array(
-                       'ip'        => $this->getIP(),
-                       'headers'   => $this->getAllHeaders(),
-                       'sessionId' => session_id()
-               );
-       }
 }
 
 /**