[Form] Fixed StringUtil::trim() to trim ZERO WIDTH SPACE (U+200B) and SOFT HYPHEN (U+00AD)

This commit is contained in:
pmishev 2020-12-05 20:51:30 +00:00
parent bda2dcdf93
commit 258bea7fd5
2 changed files with 4 additions and 2 deletions

View File

@ -72,7 +72,9 @@ class StringUtilTest extends TestCase
['000D'], ['000D'],
['0085'], ['0085'],
// zero width space // zero width space
// ['200B'], ['200B'],
// soft hyphen
['00AD'],
]; ];
} }

View File

@ -33,7 +33,7 @@ class StringUtil
*/ */
public static function trim($string) 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; return $result;
} }