Email validator: don't allow multiple hostnames

In addition to not allowing `@` multiple times in the string, we're now
checking that the *entire* string matches our regex - previously, you could
tack on anything to the end of a valid email address and have it succeed.
This commit is contained in:
xiongchiamiov
2015-02-26 10:48:56 -08:00
parent c7bbc0e566
commit bbc0a5805f
2 changed files with 4 additions and 1 deletions

View File

@@ -2070,7 +2070,7 @@ class ValidEmails(Validator):
success"""
separator = re.compile(r'[^\s,;]+')
email_re = re.compile(r'[^\s]+@[^\s]+\.[^\s]+')
email_re = re.compile(r'\A[^\s@]+@[^\s@]+\.[^\s@]+\Z')
def __init__(self, param, num = 20, **kw):
self.num = num

View File

@@ -83,3 +83,6 @@ class TestValidEmail(unittest.TestCase):
self.setUp()
self._test_failure('@example.com')
def test_two_hostnames(self):
self._test_failure('test@example.com@example.com')