Skip to content

Commit 0f02a49

Browse files
committed
General: Add additional tricky email addresses to test, with comments.
No behaviour changes are needed due to these tests, but the test code should capture the reasons for rejecting some of these addresses, so this commit adds tests and comments. Props tusharbharti.
1 parent c2b6d30 commit 0f02a49

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/phpunit/tests/formatting/isEmail.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,33 @@ public function test_returns_false_if_given_an_invalid_email_address() {
3434
'bob@your mom',
3535
3636
'" "@b.c',
37+
'h([email protected]', // bad comment
38+
'hi@',
39+
'hi@[email protected]', // double @
40+
/* The next address is not deliverable as described,
41+
* SMTP servers should strip the (ab), so it is very
42+
* likely a source of confusion or a typo.
43+
* Best rejected.
44+
*/
45+
46+
/* The next address is not globally deliverable,
47+
* so it may work with PHPMailer and break with
48+
* mail sending services. Best not allow users
49+
* to paint themselves into that corner. This also
50+
* avoids security problems like those that were
51+
* used to probe the local network around web
52+
* browsers and servers.
53+
*/
54+
'toto@to',
55+
/* Several addresses are best rejected because
56+
* we don't want to allow sending to fe80::, 192.168
57+
* and other special addresses; that too might
58+
* be used to probe the Wordpress server's local
59+
* network.
60+
*/
61+
'to@[2001:db8::1]',
62+
'to@[IPv6:2001:db8::1]',
63+
'to@[192.168.1.1]',
3764
);
3865
foreach ( $data as $datum ) {
3966
$this->assertFalse( is_email( $datum ), $datum );

0 commit comments

Comments
 (0)