Revert r44817 "Delay $wgContLang unstubbing"
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 23 Dec 2008 19:56:44 +0000 (19:56 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 23 Dec 2008 19:56:44 +0000 (19:56 +0000)
Maintainability alert -- creates duplicate code which could become out of sync!

includes/WebRequest.php

index 5d2bd26..4674712 100644 (file)
@@ -220,10 +220,13 @@ class WebRequest {
         */
        function getGPCVal( $arr, $name, $default ) {
                if( isset( $arr[$name] ) ) {
+                       global $wgContLang;
                        $data = $arr[$name];
                        if( isset( $_GET[$name] ) && !is_array( $data ) ) {
                                # Check for alternate/legacy character encoding.
-                               $data = $this->checkTitleEncoding( $data );
+                               if( isset( $wgContLang ) ) {
+                                       $data = $wgContLang->checkTitleEncoding( $data );
+                               }
                        }
                        $data = $this->normalizeUnicode( $data );
                        return $data;
@@ -231,20 +234,6 @@ class WebRequest {
                        return $default;
                }
        }
-       
-       protected function checkTitleEncoding( $s ) {
-               global $wgContLang;
-               if( !isset($wgContLang) ) return $s;
-               # Check for non-UTF-8 URLs
-               $ishigh = preg_match( '/[\x80-\xff]/', $s);
-               if( !$ishigh ) return $s;
-
-               $isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
-                       '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
-               if( $isutf8 ) return $s;
-               # Do the heavy lifting by unstubbing $wgContLang
-               return $wgContLang->iconv( $wgContLang->fallback8bitEncoding(), "utf-8", $s );
-       }
 
        /**
         * Fetch a scalar from the input or return $default if it's not set.