Extbase validator StringLength fails on counting the length of text with umlauts
In extbase StringLength validator on line 59
$stringLength = strlen($value); the length is wrong if umlaute (ä,ö,ü) in text. Probably also with other multibyte characters in text.
We fixed this quickly by using mb_strlen instead of strlen in our own extension and overwrite the StringLengthValidator class.
Is mb_strlen the solution for this problem? Is it planned to fix this problem in the validator soon?
[BUGFIX] Use mb_strlen in StringLengthValidator
By using mb_strlen for checking the length, the
check counts multibyte values now correctly.
Reviewed-by: Stephan Großberndt <firstname.lastname@example.org>
Tested-by: TYPO3com <email@example.com>
Reviewed-by: Philipp Gampe <firstname.lastname@example.org>
Tested-by: Philipp Gampe <email@example.com>
Reviewed-by: Mona Muzaffar <firstname.lastname@example.org>
Tested-by: Mona Muzaffar <email@example.com>
Reviewed-by: Mathias Brodala <firstname.lastname@example.org>
Reviewed-by: Markus Klein <email@example.com>
Tested-by: Markus Klein <firstname.lastname@example.org>
#4 Updated by Karsten Nowak (undkonsorten) over 2 years ago
Yes, I think it's soon enough. Thx.
I'm wondering that nobody else had this problem before. Maybe nobody checked lengths of strings so close to the limit. We found this bug because on our validation were two characters be left to the limit and 6 umlauts in text ;-).