Small todo note about ApiMain
[lhc/web/wiklou.git] / includes / WebRequest.php
index 0c3a996..8f2bafd 100644 (file)
@@ -239,15 +239,18 @@ class WebRequest {
         * used for undoing the evil that is magic_quotes_gpc.
         *
         * @param $arr array: will be modified
-        * @param $recursion bool Used to modify behaviour based on recursion
+        * @param $topLevel bool Specifies if the array passed is from the top
+        * level of the source. In PHP5 magic_quotes only escapes the first level
+        * of keys that belong to an array.
         * @return array the original array
+        * @see http://www.php.net/manual/en/function.get-magic-quotes-gpc.php#49612
         */
-       private function &fix_magic_quotes( &$arr, $recursion = false ) {
+       private function &fix_magic_quotes( &$arr, $topLevel = true ) {
                $clean = array();
                foreach( $arr as $key => $val ) {
                        if( is_array( $val ) ) {
-                               $cleanKey = !$recursion ? stripslashes( $key ) : $key;
-                               $clean[$cleanKey] = $this->fix_magic_quotes( $arr[$key], true );
+                               $cleanKey = $topLevel ? stripslashes( $key ) : $key;
+                               $clean[$cleanKey] = $this->fix_magic_quotes( $arr[$key], false );
                        } else {
                                $cleanKey = stripslashes( $key );
                                $clean[$cleanKey] = stripslashes( $val );
@@ -876,8 +879,6 @@ class WebRequest {
                        }
                        throw new HttpError( 403,
                                'Invalid file extension found in the path info or query string.' );
-
-                       return false;
                }
                return true;
        }
@@ -945,7 +946,7 @@ HTML;
 
        /**
         * Parse the Accept-Language header sent by the client into an array
-        * @return array( languageCode => q-value ) sorted by q-value in descending order
+        * @return array array( languageCode => q-value ) sorted by q-value in descending order
         * May contain the "language" '*', which applies to languages other than those explicitly listed.
         * This is aligned with rfc2616 section 14.4
         */
@@ -961,7 +962,7 @@ HTML;
 
                // Break up string into pieces (languages and q factors)
                $lang_parse = null;
-               preg_match_all( '/([a-z]{1,8}(-[a-z]{1,8})?|\*)\s*(;\s*q\s*=\s*(1|0(\.[0-9]+)?)?)?/',
+               preg_match_all( '/([a-z]{1,8}(-[a-z]{1,8})*|\*)\s*(;\s*q\s*=\s*(1(\.0{0,3})?|0(\.[0-9]{0,3})?)?)?/',
                        $acceptLang, $lang_parse );
 
                if ( !count( $lang_parse[1] ) ) {
@@ -1191,6 +1192,10 @@ class FauxRequest extends WebRequest {
                        $this->session = $session;
        }
 
+       /**
+        * @param $method string
+        * @throws MWException
+        */
        private function notImplemented( $method ) {
                throw new MWException( "{$method}() not implemented" );
        }