email_assessor 0.6.0 → 0.7.0
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.
- checksums.yaml +5 -5
- data/lib/email_assessor/address.rb +86 -15
- data/lib/email_assessor/version.rb +1 -1
- data/spec/email_assessor_spec.rb +20 -0
- data/vendor/disposable_domains.txt +17 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8ec3fdbcb7339d1a5d0854cc8fde6b45bc0440e8154807870a36332023be74bc
|
4
|
+
data.tar.gz: f5ccda7423d991a5e1512a96c39f38bb423bcdf6c86d51ca6f7f487ddfc3571a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c083397bac2fa9a19441e9bb2697344522b54ef7abc0bf206d6f015a185ac365aecbdc1adaa4d50f1a1d393f7c541c821ec1807eda036608dec10188fe3bee4c
|
7
|
+
data.tar.gz: 92c2b3199bba839ac4e993caa677c20c033cc27b84fcd87cf3c0f85492c0d650bdb2725776882d4eed78616eeffdf08cfc764402aecdb41d34cd81f8caf0314b
|
@@ -7,7 +7,81 @@ module EmailAssessor
|
|
7
7
|
class Address
|
8
8
|
attr_accessor :address
|
9
9
|
|
10
|
-
|
10
|
+
PROHIBITED_DOMAIN_PREFIXES = [
|
11
|
+
'.',
|
12
|
+
'-',
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
PROHIBITED_DOMAIN_CONTENT = [
|
16
|
+
'+',
|
17
|
+
'!',
|
18
|
+
'_',
|
19
|
+
'/',
|
20
|
+
' ',
|
21
|
+
'..',
|
22
|
+
'-.',
|
23
|
+
"'",
|
24
|
+
].freeze
|
25
|
+
|
26
|
+
PROHIBITED_DOMAIN_SUFFIXES = [
|
27
|
+
# none
|
28
|
+
].freeze
|
29
|
+
|
30
|
+
PROHIBITED_LOCAL_PREFIXES = [
|
31
|
+
'.',
|
32
|
+
].freeze
|
33
|
+
|
34
|
+
PROHIBITED_LOCAL_CONTENT = [
|
35
|
+
'..',
|
36
|
+
].freeze
|
37
|
+
|
38
|
+
PROHIBITED_LOCAL_SUFFIXES = [
|
39
|
+
'.',
|
40
|
+
].freeze
|
41
|
+
|
42
|
+
class << self
|
43
|
+
def prohibited_domain_regex
|
44
|
+
@prohibited_domain_content_regex ||= make_regex(
|
45
|
+
prefixes: PROHIBITED_DOMAIN_PREFIXES,
|
46
|
+
content: PROHIBITED_DOMAIN_CONTENT,
|
47
|
+
suffixes: PROHIBITED_DOMAIN_SUFFIXES
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def prohibited_local_regex
|
52
|
+
@prohibited_local_content_regex ||= make_regex(
|
53
|
+
prefixes: PROHIBITED_LOCAL_PREFIXES,
|
54
|
+
content: PROHIBITED_LOCAL_CONTENT,
|
55
|
+
suffixes: PROHIBITED_LOCAL_SUFFIXES
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def make_regex(prefixes: nil, content: nil, suffixes: nil)
|
62
|
+
parts = []
|
63
|
+
|
64
|
+
unless prefixes.nil?
|
65
|
+
prefixes.each do |prefix|
|
66
|
+
parts << "\\A#{Regexp.escape(prefix)}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
unless content.nil?
|
71
|
+
content.each do |prefix|
|
72
|
+
parts << Regexp.escape(prefix)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
unless suffixes.nil?
|
77
|
+
suffixes.each do |prefix|
|
78
|
+
parts << "#{Regexp.escape(prefix)}\\z"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
Regexp.new(parts.join("|"), Regexp::IGNORECASE)
|
83
|
+
end
|
84
|
+
end
|
11
85
|
|
12
86
|
def initialize(address)
|
13
87
|
@parse_error = false
|
@@ -21,22 +95,19 @@ module EmailAssessor
|
|
21
95
|
end
|
22
96
|
|
23
97
|
def valid?
|
98
|
+
return @valid unless @valid.nil?
|
24
99
|
return false if @parse_error
|
25
100
|
|
26
|
-
|
27
|
-
domain
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
domain.match?(%r{[a-z]\z}i) # Domain must end with letters
|
37
|
-
else
|
38
|
-
false
|
39
|
-
end
|
101
|
+
@valid =
|
102
|
+
if address.domain && address.address == @raw_address
|
103
|
+
domain = address.domain
|
104
|
+
|
105
|
+
domain.include?('.') &&
|
106
|
+
!domain.match?(self.class.prohibited_domain_regex) &&
|
107
|
+
!address.local.match?(self.class.prohibited_local_regex)
|
108
|
+
else
|
109
|
+
false
|
110
|
+
end
|
40
111
|
end
|
41
112
|
|
42
113
|
def disposable?
|
data/spec/email_assessor_spec.rb
CHANGED
@@ -36,11 +36,31 @@ describe EmailAssessor do
|
|
36
36
|
is_expected.to be_valid
|
37
37
|
end
|
38
38
|
|
39
|
+
it "is invalid if the address starts with a dot" do
|
40
|
+
user = TestUser.new(email: ".foo@bar.com")
|
41
|
+
expect(user.valid?).to be_falsey
|
42
|
+
end
|
43
|
+
|
44
|
+
it "is invalid if the address contains consecutive dots" do
|
45
|
+
user = TestUser.new(email: "foo..bar@gmail.com")
|
46
|
+
expect(user.valid?).to be_falsey
|
47
|
+
end
|
48
|
+
|
49
|
+
it "is invalid if the address ends with a dot" do
|
50
|
+
user = TestUser.new(email: "foo.@bar.com")
|
51
|
+
expect(user.valid?).to be_falsey
|
52
|
+
end
|
53
|
+
|
39
54
|
it "is invalid when domain is missing" do
|
40
55
|
user.email = "foo@.com"
|
41
56
|
is_expected.to be_invalid
|
42
57
|
end
|
43
58
|
|
59
|
+
it "is invalid when domain starts with a dot" do
|
60
|
+
user.email = "foo@.example.com"
|
61
|
+
is_expected.to be_invalid
|
62
|
+
end
|
63
|
+
|
44
64
|
it "is invalid when email is malformed" do
|
45
65
|
user.email = "foo@bar"
|
46
66
|
is_expected.to be_invalid
|
@@ -4139,6 +4139,7 @@ avuimkgtbgccejft901.ml
|
|
4139
4139
|
avuimkgtbgccejft901.tk
|
4140
4140
|
avumail.com
|
4141
4141
|
avvmail.com
|
4142
|
+
avxrja.com
|
4142
4143
|
aw.kikwet.com
|
4143
4144
|
awahal0vk1o7gbyzf0.cf
|
4144
4145
|
awahal0vk1o7gbyzf0.ga
|
@@ -4147,6 +4148,9 @@ awahal0vk1o7gbyzf0.ml
|
|
4147
4148
|
awahal0vk1o7gbyzf0.tk
|
4148
4149
|
awatum.de
|
4149
4150
|
awca.eu
|
4151
|
+
awdrt.com
|
4152
|
+
awdrt.net
|
4153
|
+
awdrt.org
|
4150
4154
|
aweather.ru
|
4151
4155
|
aweightlossguide.com
|
4152
4156
|
awemail.com
|
@@ -7826,6 +7830,7 @@ cungmuachungnhom.com
|
|
7826
7830
|
cungsuyngam.com
|
7827
7831
|
cungtam.com
|
7828
7832
|
cuoiz.com
|
7833
|
+
cuoly.com
|
7829
7834
|
cuongvumarketingseo.com
|
7830
7835
|
cupf6mdhtujxytdcoxh.cf
|
7831
7836
|
cupf6mdhtujxytdcoxh.ga
|
@@ -10305,6 +10310,7 @@ eo-z.com
|
|
10305
10310
|
eoffice.top
|
10306
10311
|
eomail.com
|
10307
10312
|
eonmech.com
|
10313
|
+
eoopy.com
|
10308
10314
|
eorbs.com
|
10309
10315
|
eos2mail.com
|
10310
10316
|
eotoplenie.ru
|
@@ -11355,6 +11361,8 @@ fitnessjockey.org
|
|
11355
11361
|
fitnessmojo.org
|
11356
11362
|
fitnessreviewsonline.com
|
11357
11363
|
fitnesszbyszko.pl
|
11364
|
+
fitschool.be
|
11365
|
+
fitschool.space
|
11358
11366
|
fittinggeeks.pl
|
11359
11367
|
fitzgeraldforjudge.com
|
11360
11368
|
five-club.com
|
@@ -12736,6 +12744,7 @@ gmailllll.ga
|
|
12736
12744
|
gmaills.eu
|
12737
12745
|
gmailmail.ga
|
12738
12746
|
gmailmarina.com
|
12747
|
+
gmailnator.com
|
12739
12748
|
gmailner.com
|
12740
12749
|
gmailnew.com
|
12741
12750
|
gmailom.co
|
@@ -12888,6 +12897,7 @@ golivejasmin.com
|
|
12888
12897
|
gomail.in
|
12889
12898
|
gomail.pgojual.com
|
12890
12899
|
gomailbox.info
|
12900
|
+
gomaild.com
|
12891
12901
|
gomaile.com
|
12892
12902
|
gomailstar.xyz
|
12893
12903
|
gomessage.ml
|
@@ -17998,6 +18008,7 @@ louboutinshoessalejp.com
|
|
17998
18008
|
louboutinshoesstoresjp.com
|
17999
18009
|
louboutinshoesus.com
|
18000
18010
|
louder1.bid
|
18011
|
+
loufad.com
|
18001
18012
|
louis-vuitton-onlinestore.com
|
18002
18013
|
louis-vuitton-outlet.com
|
18003
18014
|
louis-vuitton-outletenter.com
|
@@ -28388,6 +28399,7 @@ tempemailaddress.com
|
|
28388
28399
|
tempemails.io
|
28389
28400
|
tempinbox.co.uk
|
28390
28401
|
tempinbox.com
|
28402
|
+
tempinbox.xyz
|
28391
28403
|
tempm.cf
|
28392
28404
|
tempm.com
|
28393
28405
|
tempm.ga
|
@@ -29503,6 +29515,9 @@ tsukushiakihito.gq
|
|
29503
29515
|
tt2dx90.com
|
29504
29516
|
ttbbc.com
|
29505
29517
|
ttdfytdd.ml
|
29518
|
+
ttirv.com
|
29519
|
+
ttirv.net
|
29520
|
+
ttirv.org
|
29506
29521
|
ttoubdzlowecm7i2ua8.cf
|
29507
29522
|
ttoubdzlowecm7i2ua8.ga
|
29508
29523
|
ttoubdzlowecm7i2ua8.gq
|
@@ -32216,6 +32231,7 @@ xdvsagsdg4we.ga
|
|
32216
32231
|
xe2g.com
|
32217
32232
|
xeames.net
|
32218
32233
|
xeb9xwp7.tk
|
32234
|
+
xedmi.com
|
32219
32235
|
xemaps.com
|
32220
32236
|
xemne.com
|
32221
32237
|
xenacareholdings.com
|
@@ -32266,6 +32282,7 @@ xhkss.net
|
|
32266
32282
|
xijjfjoo.turystyka.pl
|
32267
32283
|
xilopro.com
|
32268
32284
|
xilor.com
|
32285
|
+
ximtyl.com
|
32269
32286
|
xinbo.info
|
32270
32287
|
xinbox.info
|
32271
32288
|
xinfi.com.pl
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_assessor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Wolfe Millard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -124,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
|
128
|
-
rubygems_version: 2.6.8
|
127
|
+
rubygems_version: 3.0.8
|
129
128
|
signing_key:
|
130
129
|
specification_version: 4
|
131
130
|
summary: Advanced ActiveModel email validation
|