Skip to content

Commit dd95c51

Browse files
committed
[Form] Fixed StringUtil::trim() to trim ZERO WIDTH SPACE (U+200B) and SOFT HYPHEN (U+00AD)
1 parent 77b8d68 commit dd95c51

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Tests/Util/StringUtilTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ public function spaceProvider()
7272
['000D'],
7373
['0085'],
7474
// zero width space
75-
// ['200B'],
75+
['200B'],
76+
// soft hyphen
77+
['00AD'],
7678
];
7779
}
7880

Util/StringUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private function __construct()
3333
*/
3434
public static function trim($string)
3535
{
36-
if (null !== $result = @preg_replace('/^[\pZ\p{Cc}]+|[\pZ\p{Cc}]+$/u', '', $string)) {
36+
if (null !== $result = @preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $string)) {
3737
return $result;
3838
}
3939

0 commit comments

Comments
 (0)