Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Intl] Locale::getFallback() throws an exception when the $locale length is greater than INTL_MAX_LOCALE_LEN #39100

Copy link
Copy link
Closed
@cedx

Description

@cedx
Issue body actions

Symfony version(s) affected: 5.1.8

Description
Symfony\Component\Intl\Locale::getFallback() throws an ErrorException when the length of specified $locale is greater than INTL_MAX_LOCALE_LEN.

How to reproduce

Locale::getFallback("LC_CTYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;LC_MONETARY=fr_FR.UTF-8;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=fr_FR.UTF-8;LC_ADDRESS=fr_FR.UTF-8;LC_TELEPHONE=fr_FR.UTF-8;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=fr_FR.UTF-8");
// Uncaught ErrorException: count(): Parameter must be an array or an object that implements Countable in /home/www/grossiste/vendor/symfony/intl/Locale.php:70

Possible Solution
locale_parse() returns null instead of an array when the specified locale is greater than INTL_MAX_LOCALE_LEN. So a check should be made to test whether the return value is an array. Or, the locale could be shortened by only extracting the meaningful part (i.e. just keep LC_MESSAGES=fr_FR.UTF-8?).

Additional context
Length of the system locale: 270 (i.e. the one in the given code sample).
Value of the INTL_MAX_LOCALE_LEN constant: 156.

PHP: 7.4.9 (x64) on CentOS 7.
Intl extension:

  • Internationalization support => enabled
  • ICU version => 65.1
  • ICU Data version => 65.1
  • ICU TZData version => 2019c
  • ICU Unicode version => 12.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.