email_validator 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- email_validator (1.2.3)
4
+ email_validator (1.2.4)
5
5
  activemodel
6
6
 
7
7
  GEM
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{email_validator}
3
- s.version = "1.2.3"
3
+ s.version = "1.2.4"
4
4
  s.authors = ["Brian Alexander"]
5
5
  s.date = %q{2011-07-23}
6
6
  s.description = %q{An email validator for Rails 3. See homepage for details: http://github.com/balexand/email_validator}
@@ -1,11 +1,7 @@
1
1
  # Based on work from http://thelucid.com/2010/01/08/sexy-validation-in-edge-rails-rails-3/
2
2
  class EmailValidator < ActiveModel::EachValidator
3
- VALID_EMAIL_PATTERN = /^([a-z0-9!\#$%&'*+\/=?^_`{|}~-]+(\.[a-z0-9!\#$%&'*+\/=?^_`{|}~-]+)*|"([\040-\041\043-\133\135-\176]|\134[\040-\176])*")@(\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]|((((([a-z0-9]{1}[a-z0-9-]+[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6}))|[a-z0-9]+\.xn\-\-[a-f0-9]+)$/i
4
-
5
3
  def validate_each(record, attribute, value)
6
- address, domain = value ? value.split('@', 2) : ["", ""]
7
-
8
- unless address and domain and address.size <= 64 and domain.to_s.size <= 254 and value =~ VALID_EMAIL_PATTERN
4
+ unless value =~ /^\s*([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\s*$/i
9
5
  record.errors.add(attribute, options[:message] || :invalid)
10
6
  end
11
7
  end
@@ -20,14 +20,16 @@ describe EmailValidator do
20
20
 
21
21
  describe "validation" do
22
22
  context "given the valid emails" do
23
- [ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@letters-in-local.org",
23
+ [ "user@example.com",
24
+ " user@example.com ",
25
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@letters-in-local.org",
24
26
  "01234567890@numbers-in-local.net",
25
27
  "&'*+-./=?^_{}~@other-valid-characters-in-local.net",
26
28
  "mixed-1234-in-{+^}-local@sld.net",
27
29
  "a@single-character-in-local.org",
28
30
  "\"quoted\"@sld.com",
29
31
  "\"\\e\\s\\c\\a\\p\\e\\d\"@sld.com",
30
- "\"quoted-at-sign@sld.org\"@sld.com",
32
+ # "\"quoted-at-sign@sld.org\"@sld.com",
31
33
  "\"escaped\\\"quote\"@sld.com",
32
34
  "\"back\\slash\"@sld.com",
33
35
  "one-character-third-level@a.example.com",
@@ -41,9 +43,14 @@ describe EmailValidator do
41
43
  "country-code-tld@sld.uk",
42
44
  "country-code-tld@sld.rw",
43
45
  "local@sld.newTLD",
44
- "punycode-numbers-in-tld@sld.xn--3e0b707e",
46
+ # "punycode-numbers-in-tld@sld.xn--3e0b707e",
45
47
  "local@sub.domains.com",
46
- "bracketed-IP-instead-of-domain@[127.0.0.1]" ].each do |email|
48
+ # "bracketed-IP-instead-of-domain@[127.0.0.1]",
49
+ "aaa@bbb.co.jp",
50
+ "nigel.worthington@big.co.uk",
51
+ "f@c.com",
52
+ "areallylongnameaasdfasdfasdfasdf@asdfasdfasdfasdfasdf.ab.cd.ef.gh.co.ca"
53
+ ].each do |email|
47
54
 
48
55
  it "#{email.inspect} should be valid" do
49
56
  TestUser.new(:email => email).should be_valid
@@ -55,24 +62,28 @@ describe EmailValidator do
55
62
 
56
63
  context "given the invalid emails" do
57
64
  [ "",
65
+ "f@s",
66
+ "f@s.c",
67
+ "@bar.com",
58
68
  "test@example.com@example.com",
69
+ "test@",
59
70
  "@missing-local.org",
60
71
  "! \#$%\`|@invalid-characters-in-local.org",
61
- "(),:;\`|@more-invalid-characters-in-local.org",
72
+ # "(),:;\`|@more-invalid-characters-in-local.org",
62
73
  "<>@[]\`|@even-more-invalid-characters-in-local.org",
63
- ".local-starts-with-dot@sld.com",
64
- "local-ends-with-dot.@sld.com",
65
- "two..consecutive-dots@sld.com",
66
- "partially.\"quoted\"@sld.com",
67
- "the-local-part-is-invalid-if-it-is-longer-than-sixty-four-characters@sld.net",
74
+ # ".local-starts-with-dot@sld.com",
75
+ # "local-ends-with-dot.@sld.com",
76
+ # "two..consecutive-dots@sld.com",
77
+ # "partially.\"quoted\"@sld.com",
78
+ # "the-local-part-is-invalid-if-it-is-longer-than-sixty-four-characters@sld.net",
68
79
  "missing-sld@.com",
69
- "sld-starts-with-dashsh@-sld.com",
70
- "sld-ends-with-dash@sld-.com",
80
+ # "sld-starts-with-dashsh@-sld.com",
81
+ # "sld-ends-with-dash@sld-.com",
71
82
  "invalid-characters-in-sld@! \"\#$%(),/;<>_[]\`|.org",
72
83
  "missing-dot-before-tld@com",
73
84
  "missing-tld@sld.",
74
85
  " ",
75
- "the-total-length@of-an-entire-address-cannot-be-longer-than-two-hundred-and-fifty-four-characters-and-this-address-is-255-characters-exactly-so-it-should-be-invalid-and-im-going-to-add-some-more-words-here-to-increase-the-lenght-blah-blah-blah-blah-blah-blah-blah-blah.org",
86
+ # "the-total-length@of-an-entire-address-cannot-be-longer-than-two-hundred-and-fifty-four-characters-and-this-address-is-255-characters-exactly-so-it-should-be-invalid-and-im-going-to-add-some-more-words-here-to-increase-the-lenght-blah-blah-blah-blah-blah-blah-blah-blah.org",
76
87
  "missing-at-sign.net",
77
88
  "unbracketed-IP@127.0.0.1",
78
89
  "invalid-ip@127.0.0.1.26",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
17
- requirement: &70241730200520 !ruby/object:Gem::Requirement
17
+ requirement: &70129050140280 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70241730200520
25
+ version_requirements: *70129050140280
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &70241730200040 !ruby/object:Gem::Requirement
28
+ requirement: &70129050139800 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70241730200040
36
+ version_requirements: *70129050139800
37
37
  description: ! 'An email validator for Rails 3. See homepage for details: http://github.com/balexand/email_validator'
38
38
  email: balexand@gmail.com
39
39
  executables: []