|
|
@@ -190,6 +190,19 @@ class Zend_Validate_EmailAddressTest extends PHPUnit_Framework_TestCase
|
|
|
public function testQuotedString()
|
|
|
{
|
|
|
$emailAddresses = array(
|
|
|
+ '""@domain.com', // Optional
|
|
|
+ '" "@domain.com', // x20
|
|
|
+ '"!"@domain.com', // x21
|
|
|
+ '"\""@domain.com', // \" (escaped x22)
|
|
|
+ '"#"@domain.com', // x23
|
|
|
+ '"$"@domain.com', // x24
|
|
|
+ '"Z"@domain.com', // x5A
|
|
|
+ '"["@domain.com', // x5B
|
|
|
+ '"\\\"@domain.com', // \\ (escaped x5C)
|
|
|
+ '"]"@domain.com', // x5D
|
|
|
+ '"^"@domain.com', // x5E
|
|
|
+ '"}"@domain.com', // x7D
|
|
|
+ '"~"@domain.com', // x7E
|
|
|
'"username"@example.com',
|
|
|
'"bob%jones"@domain.com',
|
|
|
'"bob jones"@domain.com',
|
|
|
@@ -204,6 +217,29 @@ class Zend_Validate_EmailAddressTest extends PHPUnit_Framework_TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Ensures that quoted-string local part is considered invalid
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testInvalidQuotedString()
|
|
|
+ {
|
|
|
+ $emailAddresses = array(
|
|
|
+ "\"\x00\"@example.com",
|
|
|
+ "\"\x01\"@example.com",
|
|
|
+ "\"\x1E\"@example.com",
|
|
|
+ "\"\x1F\"@example.com",
|
|
|
+ '"""@example.com', // x22 (not escaped)
|
|
|
+ '"\"@example.com', // x5C (not escaped)
|
|
|
+ "\"\x7F\"@example.com",
|
|
|
+ );
|
|
|
+ foreach ($emailAddresses as $input) {
|
|
|
+ $this->assertFalse($this->_validator->isValid($input), "$input failed to pass validation:\n"
|
|
|
+ . implode("\n", $this->_validator->getMessages()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* Ensures that validation fails when the e-mail is given as for display,
|
|
|
* with angle brackets around the actual address
|
|
|
*
|