Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7433519

Browse files
committed
[Intl] fix #39100
locale_parse returns null if `$locale` length is greater than `INTL_MAX_LOCALE_LEN`. throw InvalidArgumentException if $locale length is greater than INTL_MAX_LOCALE_LEN.
1 parent aad1d09 commit 7433519

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Symfony/Component/Intl/Locale.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@ public static function getDefaultFallback(): ?string
6868
public static function getFallback(string $locale): ?string
6969
{
7070
if (\function_exists('locale_parse')) {
71-
$localeSubTags = locale_parse($locale);
71+
if (null === $localeSubTags = locale_parse($locale)) {
72+
if (\defined('INTL_MAX_LOCALE_LEN')) {
73+
$message = sprintf('The length of $locale must be less than %s', INTL_MAX_LOCALE_LEN);
74+
}
75+
76+
throw new \InvalidArgumentException($message ?? '');
77+
}
78+
7279
if (1 === \count($localeSubTags)) {
7380
if ('root' !== self::$defaultFallback && self::$defaultFallback === $localeSubTags['language']) {
7481
return 'root';

0 commit comments

Comments
 (0)