Skip to content

Commit

Permalink
Fix default email_regexp config to disallow trailing non-word characters
Browse files Browse the repository at this point in the history
  • Loading branch information
samdec11 committed Jun 22, 2015
1 parent 3dc15c0 commit d49533b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/devise.rb
Expand Up @@ -106,7 +106,7 @@ module Strategies
# an one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
mattr_accessor :email_regexp
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\W]+\z/

# Range validation for password length
mattr_accessor :password_length
Expand Down
2 changes: 1 addition & 1 deletion test/devise_test.rb
Expand Up @@ -95,7 +95,7 @@ class DeviseTest < ActiveSupport::TestCase

test 'Devise.email_regexp should match valid email addresses' do
valid_emails = ["test@example.com", "jo@jo.co", "f4$_m@you.com", "testing.example@example.com.ua"]
non_valid_emails = ["rex", "test@go,com", "test user@example.com", "test_user@example server.com"]
non_valid_emails = ["rex", "test@go,com", "test user@example.com", "test_user@example server.com", "test_user@example.com."]

valid_emails.each do |email|
assert_match Devise.email_regexp, email
Expand Down

0 comments on commit d49533b

Please sign in to comment.