resourceloader: Sanitize lang code before creating Language object
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 19 Mar 2014 21:41:18 +0000 (22:41 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Wed, 19 Mar 2014 21:41:18 +0000 (22:41 +0100)
Bug: 62849
Change-Id: I6af7818c4d8d2201ac4e1a4050b92fea56d90306

includes/resourceloader/ResourceLoaderContext.php

index b90ca44..0d9ef78 100644 (file)
@@ -142,11 +142,8 @@ class ResourceLoaderContext {
         */
        public function getLanguage() {
                if ( $this->language === null ) {
-                       global $wgLang;
-                       $this->language = $this->request->getVal( 'lang' );
-                       if ( !$this->language ) {
-                               $this->language = $wgLang->getCode();
-                       }
+                       // Must be a valid language code after this point (bug 62849)
+                       $this->language = RequestContext::sanitizeLangCode( $this->request->getVal( 'lang' ) );
                }
                return $this->language;
        }
@@ -158,7 +155,7 @@ class ResourceLoaderContext {
                if ( $this->direction === null ) {
                        $this->direction = $this->request->getVal( 'dir' );
                        if ( !$this->direction ) {
-                               # directionality based on user language (see bug 6100)
+                               // Determine directionality based on user language (bug 6100)
                                $this->direction = Language::factory( $this->getLanguage() )->getDir();
                        }
                }