Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d1a0c02

Browse filesBrowse files
committed
[Validator] Update NotBlankValidator "trim" option to be Unicode aware
1 parent bb8fa4d commit d1a0c02
Copy full SHA for d1a0c02

File tree

2 files changed

+6
-6
lines changed
Filter options

2 files changed

+6
-6
lines changed

‎src/Symfony/Component/Validator/Constraints/NotBlankValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/NotBlankValidator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function validate($value, Constraint $constraint)
2929
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\NotBlank');
3030
}
3131

32-
$normalizedValue = $constraint->trim ? trim($value) : $value;
32+
$normalizedValue = $constraint->trim && is_string($value) ? preg_replace('/[\pZ\pC]+/u', '', $value) : $value;
3333

3434
if (false === $normalizedValue || (empty($normalizedValue) && '0' != $normalizedValue)) {
3535
$this->context->buildViolation($constraint->message)

‎src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public function getValidValues()
4646
public function getWhitespaces()
4747
{
4848
return array(
49-
array("\x20"),
50-
array("\x09"),
51-
array("\x0A"),
52-
array("\x0D"),
53-
array("\x0B"),
49+
array("\u{0020}"),
50+
array("\u{00A0}\u{00A0}"),
51+
array("\u{1680}\u{1680}"),
52+
array("\u{200B}"),
53+
array("\u{FEFF}"),
5454
);
5555
}
5656

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.