Skip to content

Commit 80c1ac4

Browse files
committed
Merge pull request zendframework#278 from jeremyquinton/issue-162
Fixes zendframework#162 - Validate quoted local part of email addresses
2 parents 1f8a160 + 43f620e commit 80c1ac4

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Validate/EmailAddress.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,12 @@ private function _validateLocalPart()
424424
if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->_localPart)) {
425425
$result = true;
426426
} else {
427-
// Try quoted string format
428-
429-
// Quoted-string characters are: DQUOTE *([FWS] qtext/quoted-pair) [FWS] DQUOTE
430-
// qtext: Non white space controls, and the rest of the US-ASCII characters not
431-
// including "\" or the quote character
432-
$noWsCtl = '\x01-\x08\x0b\x0c\x0e-\x1f\x7f';
433-
$qtext = $noWsCtl . '\x21\x23-\x5b\x5d-\x7e';
434-
$ws = '\x20\x09';
435-
if (preg_match('/^\x22([' . $ws . $qtext . '])*[$ws]?\x22$/', $this->_localPart)) {
427+
// Try quoted string format (RFC 5321 Chapter 4.1.2)
428+
429+
// Quoted-string characters are: DQUOTE *(qtext/quoted-pair) DQUOTE
430+
$qtext = '\x20-\x21\x23-\x5b\x5d-\x7e'; // %d32-33 / %d35-91 / %d93-126
431+
$quotedPair = '\x20-\x7e'; // %d92 %d32-126
432+
if (preg_match('/^"(['. $qtext .']|\x5c[' . $quotedPair . '])*"$/', $this->localPart)) {
436433
$result = true;
437434
} else {
438435
$this->_error(self::DOT_ATOM);

0 commit comments

Comments
 (0)