From: Antoine Musso Date: Sat, 5 Feb 2011 22:55:09 +0000 (+0000) Subject: Avoid code duplication for Language::isValidCode X-Git-Tag: 1.31.0-rc.0~32176 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=979880b77425c1bc72f86dcbbaa56ea1cf206f56;p=lhc%2Fweb%2Fwiklou.git Avoid code duplication for Language::isValidCode r81335 changed the way we validate language code by introducing: strcspn( $code, "/\\\000" ) !== strlen( $code ) That code was later made a function in r81340 but some conditional tests were not updated to reflect this change. --- diff --git a/languages/Language.php b/languages/Language.php index 3b87db7515..9631ce2fa7 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -156,9 +156,7 @@ class Language { static $recursionLevel = 0; // Protect against path traversal below - if ( !Language::isValidCode( $code ) - || strcspn( $code, "/\\\000" ) !== strlen( $code ) ) - { + if ( !Language::isValidCode( $code ) ) { throw new MWException( "Invalid language code \"$code\"" ); } @@ -2829,9 +2827,7 @@ class Language { */ static function getFileName( $prefix = 'Language', $code, $suffix = '.php' ) { // Protect against path traversal - if ( !Language::isValidCode( $code ) - || strcspn( $code, "/\\\000" ) !== strlen( $code ) ) - { + if ( !Language::isValidCode( $code ) ) { throw new MWException( "Invalid language code \"$code\"" ); }