Check validity of language code before constructing NumberFormatter
The underlying libICU only allows language codes of length 157 or less (ULOC_FULLNAME_CAPACITY from https://github.com/unicode-org/icu/blob/master/icu4c/source/common/unicode/uloc.h). Bug: T267589 Change-Id: I1e182053dec6c6f8ad379cde544b829f410664d3
This commit is contained in:
parent
508d3a0227
commit
5d145154ca
2 changed files with 7 additions and 2 deletions
|
|
@ -134,7 +134,9 @@ class LanguageNameUtils {
|
|||
$this->validCodeCache[$code] =
|
||||
// Protect against path traversal
|
||||
strcspn( $code, ":/\\\000&<>'\"" ) === strlen( $code ) &&
|
||||
!preg_match( MediaWikiTitleCodec::getTitleInvalidRegex(), $code );
|
||||
!preg_match( MediaWikiTitleCodec::getTitleInvalidRegex(), $code ) &&
|
||||
// libicu sets ULOC_FULLNAME_CAPACITY to 157; stay comfortably lower
|
||||
strlen( $code ) <= 128;
|
||||
}
|
||||
return $this->validCodeCache[$code];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3302,7 +3302,10 @@ class Language {
|
|||
if ( !$noSeparators ) {
|
||||
$separatorTransformTable = $this->separatorTransformTable();
|
||||
$digitGroupingPattern = $this->digitGroupingPattern();
|
||||
$code = $wgTranslateNumerals ? $this->getCode() : 'C';
|
||||
$code = $this->getCode();
|
||||
if ( !( $wgTranslateNumerals && $this->langNameUtils->isValidCode( $code ) ) ) {
|
||||
$code = 'C'; // POSIX system default locale
|
||||
}
|
||||
|
||||
if ( $digitGroupingPattern ) {
|
||||
$fmt = new NumberFormatter(
|
||||
|
|
|
|||
Loading…
Reference in a new issue