Skip to content

Commit ec7ed3e

Browse files
committed
Enable FILTER_FLAG_EMAIL_UNICODE for email format if present (jsonrainbow#398)
1 parent 6400012 commit ec7ed3e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/JsonSchema/Constraints/FormatConstraint.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ public function check(&$element, $schema = null, JsonPointer $path = null, $i =
105105
break;
106106

107107
case 'email':
108-
if (null === filter_var($element, FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE)) {
108+
$filterFlags = FILTER_NULL_ON_FAILURE;
109+
if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
110+
// Only available from PHP >= 7.1.0, so ignore it for coverage checks
111+
$filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE'); // @codeCoverageIgnore
112+
}
113+
if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
109114
$this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
110115
}
111116
break;

0 commit comments

Comments
 (0)