Skip to content

[Form] Localized number with grouping not accepted #7609

Closed
@WARrior-Alex

Description

@WARrior-Alex

With ru or fi locales and grouping enabled number (and money) field validator returns error:
"Error: This value is not valid."
To reproduce, just add number or money field to the form and use ru or fi locale. This issue happens because grouping symbol for those locales is 2-byte unicode (ex. for ru locale codes 194 and 160). But in vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php you are using strlen() function (line 135) to validate field and this function is NOT multibyte safe. I'm not sure, if you support non-UTF8 encodings, but if not, just replace
strlen($value)
with
mb_strlen($value, 'utf8')

php-intl extension is installed, version 1.1.0 (ICU version 4.8.1.1)
Symfony 2.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions