Merge pull request #407 from alphagov/fix_uppercase_white_list_bug

Fix issue with uppercase in the domain name.
This commit is contained in:
NIcholas Staples
2016-04-07 09:35:31 +01:00
2 changed files with 5 additions and 2 deletions

View File

@@ -36,5 +36,5 @@ class ValidEmailDomainRegex(object):
"https://docs.google.com/forms/d/1AL8U-xJX_HAFEiQiJszGQw0PcEaEUnYATSntEghNDGo/viewform")
valid_domains = current_app.config.get('EMAIL_DOMAIN_REGEXES', [])
email_regex = "[^\@^\s]+@([^@^\\.^\\s]+\.)*({})$".format("|".join(valid_domains))
if not re.match(email_regex, field.data):
if not re.match(email_regex, field.data.lower()):
raise ValidationError(message)

View File

@@ -57,6 +57,8 @@ def _gen_mock_field(x):
@pytest.mark.parametrize("email", [
'test@gov.uk',
'test@GOV.UK',
'test@gov.uK',
'test@test.test.gov.uk',
'test@test.gov.uk',
'test@mod.uk',
@@ -71,7 +73,8 @@ def _gen_mock_field(x):
'test@nhs.net',
'test@gov.nhs.net',
'test@police.uk',
'test@gov.police.uk'
'test@gov.police.uk',
'test@GOV.PoliCe.uk',
])
def test_valid_list_of_white_list_email_domains(app_, email):
with app_.test_request_context():