Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow uppercase in emails #195

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/lib/email_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def self.email_is_allowed_advanced?(email)
# which domains are allowed to be requested for a gds-users account
def self.allowed_emails_regexp
/\A(#{Regexp.union(
/([a-z.\-\']+@digital\.cabinet-office\.gov\.uk,?\s*)/,
/([a-z.\-\']+@cabinetoffice\.gov\.uk,?\s*)/,
/([a-z.\-\']+@softwire\.com,?\s*)/,
/([a-z.\-\']+@fidusinfosec\.com,?\s*)/,
/([a-zA-Z.\-\']+@digital\.cabinet-office\.gov\.uk,?\s*)/,
/([a-zA-Z.\-\']+@cabinetoffice\.gov\.uk,?\s*)/,
/([a-zA-Z.\-\']+@softwire\.com,?\s*)/,
/([a-zA-Z.\-\']+@fidusinfosec\.com,?\s*)/,
)})+\z/
end

Expand Down
5 changes: 5 additions & 0 deletions test/lib/email_validator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class EmailValidatorTest < ActiveSupport::TestCase
assert_match EmailValidator.allowed_emails_regexp, emails
end

test 'Mixed case emails are matched by the allowed emails regexp' do
email = '[email protected]'
assert_match EmailValidator.allowed_emails_regexp, email
end

test 'Other email addresses should not match emails regexp' do
email = '[email protected]'
assert_no_match EmailValidator.allowed_emails_regexp, email
Expand Down