email_address_validator 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/LICENSE +1 -0
- data/README.md +87 -0
- data/Rakefile +15 -0
- data/email_address_validator.gemspec +29 -0
- data/grammars/domain.kpeg +28 -0
- data/grammars/rfc2822.kpeg +152 -0
- data/grammars/rfc822.kpeg +76 -0
- data/lib/email_address_validator.rb +103 -0
- data/lib/email_address_validator/domain-parser.rb +503 -0
- data/lib/email_address_validator/rfc2822-parser.rb +2543 -0
- data/lib/email_address_validator/rfc822-parser.rb +1326 -0
- data/lib/email_address_validator/version.rb +3 -0
- data/spec/email_address_validator_spec.rb +120 -0
- data/spec/spec_helper.rb +2 -0
- data/version.txt +1 -0
- metadata +95 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
|
2
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
3
|
+
|
4
|
+
describe EmailAddressValidator do
|
5
|
+
VALID_COMMON =
|
6
|
+
["simple@example.com", "\"Abc\@def\"@example.com",
|
7
|
+
"\"Fred Bloggs\"@example.com", "\"Joe\\Blow\"@example.com",
|
8
|
+
"\"Abc@def\"@example.com", "customer/department=shipping@example.com",
|
9
|
+
"$A12345@example.com", "!def!xyz%abc@example.com",
|
10
|
+
"\"Chris Jones\" <c@a.test>",
|
11
|
+
"Group:\"Chris Jones\" <c@a.test>,joe@where.test,John <jdoe@one.test>;",
|
12
|
+
"A Group:\"Chris Jones\" <c@a.test>,joe@where.test,John <jdoe@one.test>;",
|
13
|
+
"l3tt3rsAndNumb3rs@domain.com", "has-dash@domain.com",
|
14
|
+
"hasApostrophe.o'leary@domain.org", "uncommonTLD@domain.museum",
|
15
|
+
"lettersInDomain@911.com", "underscore_inLocal@domain.net",
|
16
|
+
"subdomain@sub.domain.com", "local@dash-inDomain.com",
|
17
|
+
"dot.inLocal@foo.com", "a@singleLetterLocal.org",
|
18
|
+
"singleLetterDomain@x.org", "&*=?^+{}'~@validCharsInLocal.net",
|
19
|
+
"foor@bar.newTLD", "domainStartsWithDash@-domain.com",
|
20
|
+
"local@SecondLevelDomainNamesValidEvenIfTheyAreLongerThan64Charactersss.org",
|
21
|
+
"ipsaredomains@127.0.0.1.26", "domainEndsWithDash@domain-.com",
|
22
|
+
"numbersInTLD@domain.c0m", "IPInsteadOfDomain@127.0.0.1",
|
23
|
+
|
24
|
+
"shortipv6@[::1]", "fullipv6@[2001:0DB7:1982:A098:2001:0DB7:1982:A098]",
|
25
|
+
"toomanyoctets@[2001:0DB7:1982:A098:2001:0DB7:1982:A098:8991]",
|
26
|
+
"garbageipv6@[nthueonthueonhurc]",
|
27
|
+
"missingDot@com"
|
28
|
+
]
|
29
|
+
|
30
|
+
VALID_DOMAIN_COMMON = %w!evan@foo.com evan@com evan@blah.foo.com
|
31
|
+
evan@foo-bar.com evan@foo3bar.com evan@foo-3bar.com
|
32
|
+
evan@3foo-4bar.com!
|
33
|
+
|
34
|
+
INVALID_DOMAIN_COMMON = %w!evan@-foo.com evan@foo-.com evan@foo.c$m evan@-
|
35
|
+
evan@thisismorethan63octetssoitwillfailbecauserfc1123sayssoandwedowhatitsays-bar.com
|
36
|
+
evan@thisismorethan255octetssoitwillfailbecauserfc1123sayssoandwedowhatitsays.thisismorethan255octetssoitwillfailbecauserfc1123sayssoandwedowhatitsays.thisismorethan255octetssoitwillfailbecauserfc1123sayssoandwedowhatitsays.thisismorethan255octetssoitwillfailbecauserfc1123sayssoandwedowhatitsays!
|
37
|
+
|
38
|
+
INVALID_COMMON =
|
39
|
+
["NotAnEmail", "@NotAnEmail", "nodomain@", "missingDomain@.com",
|
40
|
+
"@missingLocal.org", "missingatSign.net",
|
41
|
+
"two@@signs.com", "colonButNoPort@127.0.0.1:",
|
42
|
+
".localStartsWithDot@domain.com",
|
43
|
+
"localEndsWithDot.@domain.com", "two..consecutiveDots@domain.com",
|
44
|
+
"missingTLD@domain.",
|
45
|
+
"! \"#\$%(),/;<>[]`|@CharsInLocal.org",
|
46
|
+
"IPAndPort@127.0.0.1:25",
|
47
|
+
"CharsInDomain@! \"#\$%(),/;<>_[]`|.org",
|
48
|
+
]
|
49
|
+
|
50
|
+
VALID = VALID_COMMON + [ "c@(Chris's host.)public.example" ]
|
51
|
+
|
52
|
+
VALID_ADDRSPEC = ["l3tt3rsAndNumb3rs@domain.com", "has-dash@domain.com"]
|
53
|
+
|
54
|
+
INVALID = INVALID_COMMON
|
55
|
+
|
56
|
+
VALID.each do |addr|
|
57
|
+
it "should recognize <#{addr}> as valid" do
|
58
|
+
EmailAddressValidator.validate_822(addr).should be_true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
INVALID.each do |addr|
|
63
|
+
it "should recognize <#{addr}> as invalid" do
|
64
|
+
EmailAddressValidator.validate_822(addr).should be_false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
VALID_ADDRSPEC.each do |addr|
|
69
|
+
it "should recognize <#{addr}> as valid" do
|
70
|
+
EmailAddressValidator.validate_822_addr(addr).should be_true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
VALID_DOMAIN_COMMON.each do |addr|
|
75
|
+
it "should validate the domain of <#{addr}> as valid" do
|
76
|
+
EmailAddressValidator.validate_822(addr, true).should be_true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
INVALID_DOMAIN_COMMON.each do |addr|
|
81
|
+
it "should validate the domain of <#{addr}> as invalid" do
|
82
|
+
EmailAddressValidator.validate_822(addr, true).should be_false
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
VALID_MODERN = VALID_COMMON
|
87
|
+
|
88
|
+
INVALID_MODERN = INVALID_COMMON
|
89
|
+
|
90
|
+
VALID_MODERN.each do |addr|
|
91
|
+
it "should recognize modern <#{addr}> as valid" do
|
92
|
+
EmailAddressValidator.validate_2822_addr(addr).should be_true
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
INVALID_MODERN.each do |addr|
|
97
|
+
it "should recognize modern <#{addr}> as invalid" do
|
98
|
+
EmailAddressValidator.validate_2822_addr(addr).should be_false
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
VALID_ADDRSPEC.each do |addr|
|
103
|
+
it "should recognize modern <#{addr}> as valid" do
|
104
|
+
EmailAddressValidator.validate_2822_addr(addr).should be_true
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
VALID_DOMAIN_COMMON.each do |addr|
|
109
|
+
it "should validate the domain of <#{addr}> as valid" do
|
110
|
+
EmailAddressValidator.validate_2822(addr, true).should be_true
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
INVALID_DOMAIN_COMMON.each do |addr|
|
115
|
+
it "should validate the domain of <#{addr}> as invalid" do
|
116
|
+
EmailAddressValidator.validate_822(addr, true).should be_false
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/version.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: email_address_validator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Evan Phoenix
|
9
|
+
- Andrew Cholakian
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2011-03-24 00:00:00 -07:00
|
15
|
+
default_executable:
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: rspec
|
19
|
+
prerelease: false
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 2.4.0
|
26
|
+
type: :development
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: kpeg
|
30
|
+
prerelease: false
|
31
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.7.0
|
37
|
+
type: :development
|
38
|
+
version_requirements: *id002
|
39
|
+
description: RFC Compliant Email Address Parsing using the KPEG grammars.
|
40
|
+
email:
|
41
|
+
- andrew@andrewvc.com
|
42
|
+
executables: []
|
43
|
+
|
44
|
+
extensions: []
|
45
|
+
|
46
|
+
extra_rdoc_files:
|
47
|
+
- LICENSE
|
48
|
+
- README.md
|
49
|
+
files:
|
50
|
+
- .gitignore
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- email_address_validator.gemspec
|
55
|
+
- grammars/domain.kpeg
|
56
|
+
- grammars/rfc2822.kpeg
|
57
|
+
- grammars/rfc822.kpeg
|
58
|
+
- lib/email_address_validator.rb
|
59
|
+
- lib/email_address_validator/domain-parser.rb
|
60
|
+
- lib/email_address_validator/rfc2822-parser.rb
|
61
|
+
- lib/email_address_validator/rfc822-parser.rb
|
62
|
+
- lib/email_address_validator/version.rb
|
63
|
+
- spec/email_address_validator_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
- version.txt
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: https://github.com/andrewvc/rfc-822
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: "0"
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project: email_address_validator
|
90
|
+
rubygems_version: 1.6.0
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: RFC 2822/822 Email Address Parsing.
|
94
|
+
test_files: []
|
95
|
+
|