Merge "Less wild whitespace"
[lhc/web/wiklou.git] / includes / WebRequest.php
index 7005416..8cf25bb 100644 (file)
@@ -382,7 +382,7 @@ class WebRequest {
 
        /**
         * Unset an arbitrary value from our get/post data.
-        *
+        *
         * @param $key String: key name to use
         * @return Mixed: old value if one was present, null otherwise
         */
@@ -1044,14 +1044,21 @@ HTML;
         *
         * @since 1.19
         *
+        * @throws MWException
         * @return String
         */
        protected function getRawIP() {
-               if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
-                       return IP::canonicalize( $_SERVER['REMOTE_ADDR'] );
-               } else {
+               if ( !isset( $_SERVER['REMOTE_ADDR'] ) ) {
                        return null;
                }
+
+               if ( is_array( $_SERVER['REMOTE_ADDR'] ) || strpos( $_SERVER['REMOTE_ADDR'], ',' ) !== false ) {
+                       throw new MWException( __METHOD__ . " : Could not determine the remote IP address due to multiple values." );
+               } else {
+                       $ipchain = $_SERVER['REMOTE_ADDR'];
+               }
+
+               return IP::canonicalize( $ipchain );
        }
 
        /**
@@ -1329,8 +1336,10 @@ class FauxRequest extends WebRequest {
         * @return mixed
         */
        public function getSessionData( $key ) {
-               if( isset( $this->session[$key] ) )
+               if( isset( $this->session[$key] ) ) {
                        return $this->session[$key];
+               }
+               return null;
        }
 
        /**