Avoid fatal errors with uselang=s
authorNiklas Laxström <niklas.laxstrom@gmail.com>
Wed, 3 Apr 2013 10:35:29 +0000 (10:35 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 5 Apr 2013 14:04:02 +0000 (14:04 +0000)
languages is not a subclass of Language

Force valid built-in language codes to be at least two letters long.

Bug: 46710
Change-Id: Ife8885ed4bdb3a017a54e063f5dc58468ba231d5

languages/Language.php

index 57d456a..156f7b0 100644 (file)
@@ -357,7 +357,7 @@ class Language {
                        throw new MWException( __METHOD__ . " must be passed a string, $type given$addmsg" );
                }
 
-               return (bool)preg_match( '/^[a-z0-9-]+$/i', $code );
+               return (bool)preg_match( '/^[a-z0-9-]{2,}$/i', $code );
        }
 
        /**