From 258bea7fd55910ae958ab9d8899830b39e07501f Mon Sep 17 00:00:00 2001 From: pmishev Date: Sat, 5 Dec 2020 20:51:30 +0000 Subject: [PATCH] [Form] Fixed StringUtil::trim() to trim ZERO WIDTH SPACE (U+200B) and SOFT HYPHEN (U+00AD) --- src/Symfony/Component/Form/Tests/Util/StringUtilTest.php | 4 +++- src/Symfony/Component/Form/Util/StringUtil.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/Util/StringUtilTest.php b/src/Symfony/Component/Form/Tests/Util/StringUtilTest.php index 755b842e61..1d162250d1 100644 --- a/src/Symfony/Component/Form/Tests/Util/StringUtilTest.php +++ b/src/Symfony/Component/Form/Tests/Util/StringUtilTest.php @@ -72,7 +72,9 @@ class StringUtilTest extends TestCase ['000D'], ['0085'], // zero width space -// ['200B'], + ['200B'], + // soft hyphen + ['00AD'], ]; } diff --git a/src/Symfony/Component/Form/Util/StringUtil.php b/src/Symfony/Component/Form/Util/StringUtil.php index ce507e9ee2..fe372cf196 100644 --- a/src/Symfony/Component/Form/Util/StringUtil.php +++ b/src/Symfony/Component/Form/Util/StringUtil.php @@ -33,7 +33,7 @@ class StringUtil */ public static function trim($string) { - if (null !== $result = @preg_replace('/^[\pZ\p{Cc}]+|[\pZ\p{Cc}]+$/u', '', $string)) { + if (null !== $result = @preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $string)) { return $result; }