Skip to content

Commit 8f96c7a

Browse files
author
bahram
committed
[Intl] fix #39100
locale_parse returns null if `$locale` length is greater than `INTL_MAX_LOCALE_LEN`. return null if locale_parse return null.
1 parent 5fe91c9 commit 8f96c7a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Symfony/Component/Intl/Locale.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ public static function getFallback(string $locale): ?string
6969
{
7070
if (\function_exists('locale_parse')) {
7171
$localeSubTags = locale_parse($locale);
72+
73+
if (null === $localeSubTags) {
74+
return null;
75+
}
76+
7277
if (1 === \count($localeSubTags)) {
7378
if ('root' !== self::$defaultFallback && self::$defaultFallback === $localeSubTags['language']) {
7479
return 'root';

src/Symfony/Component/Intl/Tests/LocaleTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,13 @@ public function testDefaultRootFallback()
7070

7171
Locale::setDefaultFallback($prev);
7272
}
73+
74+
public function testGetFallbackLongLocale()
75+
{
76+
$longLocale = 'LC_TYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;'
77+
. 'LC_MONETARY=fr_FR.UTF-8;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=fr_FR.UTF-8;'
78+
. 'LC_ADDRESS=fr_FR.UTF-8;LC_TELEPHONE=fr_FR.UTF-8;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=fr_FR.UTF-8';
79+
80+
$this->assertNull(Locale::getFallback($longLocale));
81+
}
7382
}

0 commit comments

Comments
 (0)