[1.6.x] Fixed an email validation regression

Thanks Vincent Wagelaar for the report.
Backport of 11b7b9ad from master.
This commit is contained in:
Claude Paroz 2013-07-20 18:00:23 +02:00
parent 706e542eb5
commit 48516d3b85
2 changed files with 2 additions and 1 deletions

View File

@ -87,7 +87,7 @@ class EmailValidator(object):
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)', # quoted-string r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)', # quoted-string
re.IGNORECASE) re.IGNORECASE)
domain_regex = re.compile( domain_regex = re.compile(
r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?$)' # domain r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,})\.?$' # domain
# literal form, ipv4 address (SMTP 4.1.3) # literal form, ipv4 address (SMTP 4.1.3)
r'|^\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', r'|^\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$',
re.IGNORECASE) re.IGNORECASE)

View File

@ -46,6 +46,7 @@ TEST_DATA = (
(validate_email, 'example@-invalid.com', ValidationError), (validate_email, 'example@-invalid.com', ValidationError),
(validate_email, 'example@inv-.alid-.com', ValidationError), (validate_email, 'example@inv-.alid-.com', ValidationError),
(validate_email, 'example@inv-.-alid.com', ValidationError), (validate_email, 'example@inv-.-alid.com', ValidationError),
(validate_email, 'test@example.com\n\n<script src="x.js">', ValidationError),
# Quoted-string format (CR not allowed) # Quoted-string format (CR not allowed)
(validate_email, '"\\\011"@here.com', None), (validate_email, '"\\\011"@here.com', None),
(validate_email, '"\\\012"@here.com', ValidationError), (validate_email, '"\\\012"@here.com', ValidationError),