mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
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:
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user