Permalink
Browse files

Improve the regexp a bit more.

  • Loading branch information...
1 parent 7396c69 commit 7b1418be3b33ac77cb185c15e641292767112f08 @josevalim josevalim committed Aug 29, 2011
Showing with 2 additions and 2 deletions.
  1. +1 −1 lib/devise.rb
  2. +1 −1 test/models/validatable_test.rb
View
@@ -108,7 +108,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[^@]+@[^@]+\z/
+ @@email_regexp = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/
@Bregor

Bregor Aug 31, 2011

Contributor

Fails in Chromium 1{4,5}, Firefox 6 when browser validation is on (with simple_form)

Input source:

<input class="string email required" id="user_email" maxlength="255" name="user[email]" pattern="\A[^@]+@([^@\.]+\.)+[^@\.]+\z" placeholder="login@yamoney.ru" required="required" size="30" type="email" value="">

Result:

Call center
Uploaded with Skitch!
@josevalim

josevalim Aug 31, 2011

Owner

Works in Ruby. This is a SimpleForm bug, we cannot assume Ruby regexps will translate directly to Javascript regexps.

@josevalim

josevalim Aug 31, 2011

Owner

Maybe we could make this particular regexp work by escaping \A as \A or a few changes, but I don't consider this to be Devise fault.

@josevalim

josevalim Aug 31, 2011

Owner

Yes, but Devise has no responsibility if someone is assuming that its Regexps will work fine on Javascript without translation.

@rafaelfranca

rafaelfranca Aug 31, 2011

Collaborator

@Bregor (💣) we'll change it on the SimpleForm. plataformatec/simple_form#310

@Bregor

Bregor Aug 31, 2011

Contributor

Thanks, guys.

# Range validation for password length
mattr_accessor :password_length
@@ -29,7 +29,7 @@ class ValidatableTest < ActiveSupport::TestCase
assert user.invalid?
assert_not_equal 'is invalid', user.errors[:email].join
- %w{invalid_email_format 123 $$$ () ☃}.each do |email|
+ %w{invalid_email_format 123 $$$ () ☃ bla@bla.}.each do |email|
user.email = email
assert user.invalid?, 'should be invalid with email ' << email
assert_equal 'is invalid', user.errors[:email].join

0 comments on commit 7b1418b

Please sign in to comment.