valid_email2 3.5.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +7 -1
- data/config/disposable_email_domains.txt +8 -2
- data/lib/valid_email2/address.rb +12 -1
- data/lib/valid_email2/email_validator.rb +5 -1
- data/lib/valid_email2/version.rb +1 -1
- data/pull_mailchecker_emails.rb +1 -1
- data/spec/valid_email2_spec.rb +21 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6543e0ca764df6ed5698a864b232260e456a0fc3b8e3f82918122e21cdca0c3
|
4
|
+
data.tar.gz: 989805e58182e1b4ab18b9a16a80a9507465f840bea19840abebe841d628dfa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59813d38f00f9c75cbaae7d944f47d50f9e0239f740c468e8718c51345af324f46411e13b2796c5881769a62127345529be92ae374d07082d07e06610e50b62a
|
7
|
+
data.tar.gz: 131d25e900327ff67b0cd80e17ecc0de83462394d8094cafbed93780ec9b4d472b8e1b95591dc8c894fc8c4f47a8a5a60d31d7fa3c6733210f1b429ca79ff72c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## Version 3.6.0
|
2
|
+
* Add strict_mx validation https://github.com/micke/valid_email2/pull/173
|
3
|
+
|
1
4
|
## Version 3.5.0
|
2
5
|
* Disallow emails starting with a dot https://github.com/micke/valid_email2/pull/170
|
3
6
|
* Add option to whitelist domains from MX check https://github.com/micke/valid_email2/pull/167
|
data/README.md
CHANGED
@@ -43,10 +43,14 @@ class User < ActiveRecord::Base
|
|
43
43
|
end
|
44
44
|
```
|
45
45
|
|
46
|
-
To validate that the domain has
|
46
|
+
To validate that the domain has an MX record or A record:
|
47
47
|
```ruby
|
48
48
|
validates :email, 'valid_email_2/email': { mx: true }
|
49
49
|
```
|
50
|
+
To validate strictly that the domain has an MX record:
|
51
|
+
```ruby
|
52
|
+
validates :email, 'valid_email_2/email': { strict_mx: true }
|
53
|
+
```
|
50
54
|
|
51
55
|
To validate that the domain is not a disposable email (checks domain and MX server):
|
52
56
|
```ruby
|
@@ -109,6 +113,7 @@ address = ValidEmail2::Address.new("lisinge@gmail.com")
|
|
109
113
|
address.valid? => true
|
110
114
|
address.disposable? => false
|
111
115
|
address.valid_mx? => true
|
116
|
+
address.valid_strict_mx? => true
|
112
117
|
address.subaddressed? => false
|
113
118
|
```
|
114
119
|
|
@@ -120,6 +125,7 @@ Do so by adding this in your `spec_helper`:
|
|
120
125
|
```ruby
|
121
126
|
config.before(:each) do
|
122
127
|
allow_any_instance_of(ValidEmail2::Address).to receive(:valid_mx?).and_return(true)
|
128
|
+
allow_any_instance_of(ValidEmail2::Address).to receive(:valid_strict_mx?).and_return(true)
|
123
129
|
end
|
124
130
|
```
|
125
131
|
|
@@ -4174,6 +4174,7 @@ avuimkgtbgccejft901.ml
|
|
4174
4174
|
avuimkgtbgccejft901.tk
|
4175
4175
|
avumail.com
|
4176
4176
|
avvmail.com
|
4177
|
+
avxrja.com
|
4177
4178
|
aw.kikwet.com
|
4178
4179
|
awahal0vk1o7gbyzf0.cf
|
4179
4180
|
awahal0vk1o7gbyzf0.ga
|
@@ -12324,6 +12325,7 @@ gd6ubc0xilchpozgpg.gq
|
|
12324
12325
|
gd6ubc0xilchpozgpg.ml
|
12325
12326
|
gd6ubc0xilchpozgpg.tk
|
12326
12327
|
gdb.armageddon.org
|
12328
|
+
gdf.it
|
12327
12329
|
gdfretertwer.com
|
12328
12330
|
gdmail.top
|
12329
12331
|
gdradr.com
|
@@ -12788,6 +12790,7 @@ gmailllll.ga
|
|
12788
12790
|
gmaills.eu
|
12789
12791
|
gmailmail.ga
|
12790
12792
|
gmailmarina.com
|
12793
|
+
gmailnator.com
|
12791
12794
|
gmailner.com
|
12792
12795
|
gmailnew.com
|
12793
12796
|
gmailom.co
|
@@ -12938,6 +12941,7 @@ golivejasmin.com
|
|
12938
12941
|
gomail.in
|
12939
12942
|
gomail.pgojual.com
|
12940
12943
|
gomailbox.info
|
12944
|
+
gomaild.com
|
12941
12945
|
gomaile.com
|
12942
12946
|
gomailstar.xyz
|
12943
12947
|
gomessage.ml
|
@@ -18053,6 +18057,7 @@ louboutinshoessalejp.com
|
|
18053
18057
|
louboutinshoesstoresjp.com
|
18054
18058
|
louboutinshoesus.com
|
18055
18059
|
louder1.bid
|
18060
|
+
loufad.com
|
18056
18061
|
louis-vuitton-onlinestore.com
|
18057
18062
|
louis-vuitton-outlet.com
|
18058
18063
|
louis-vuitton-outletenter.com
|
@@ -31422,7 +31427,6 @@ webcontact-france.eu
|
|
31422
31427
|
webcool.club
|
31423
31428
|
webdesign-guide.info
|
31424
31429
|
webdesign-romania.net
|
31425
|
-
webdesignspecialist.com.au
|
31426
31430
|
webdesigrsbio.gr
|
31427
31431
|
webdespro.ru
|
31428
31432
|
webdev-pro.ru
|
@@ -32327,6 +32331,7 @@ xdvsagsdg4we.ga
|
|
32327
32331
|
xe2g.com
|
32328
32332
|
xeames.net
|
32329
32333
|
xeb9xwp7.tk
|
32334
|
+
xedmi.com
|
32330
32335
|
xemaps.com
|
32331
32336
|
xemne.com
|
32332
32337
|
xenacareholdings.com
|
@@ -32377,6 +32382,7 @@ xhkss.net
|
|
32377
32382
|
xijjfjoo.turystyka.pl
|
32378
32383
|
xilopro.com
|
32379
32384
|
xilor.com
|
32385
|
+
ximtyl.com
|
32380
32386
|
xinbo.info
|
32381
32387
|
xinbox.info
|
32382
32388
|
xinfi.com.pl
|
@@ -33698,4 +33704,4 @@ zzv2bfja5.pl
|
|
33698
33704
|
zzz.co
|
33699
33705
|
zzz.com
|
33700
33706
|
zzzmail.pl
|
33701
|
-
zzzzzzzzzzzzz.com
|
33707
|
+
zzzzzzzzzzzzz.com
|
data/lib/valid_email2/address.rb
CHANGED
@@ -85,6 +85,12 @@ module ValidEmail2
|
|
85
85
|
def valid_mx?
|
86
86
|
return false unless valid?
|
87
87
|
|
88
|
+
mx_or_a_servers.any?
|
89
|
+
end
|
90
|
+
|
91
|
+
def valid_strict_mx?
|
92
|
+
return false unless valid?
|
93
|
+
|
88
94
|
mx_servers.any?
|
89
95
|
end
|
90
96
|
|
@@ -119,7 +125,12 @@ module ValidEmail2
|
|
119
125
|
|
120
126
|
def mx_servers
|
121
127
|
@mx_servers ||= Resolv::DNS.open do |dns|
|
122
|
-
|
128
|
+
dns.getresources(address.domain, Resolv::DNS::Resource::IN::MX)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def mx_or_a_servers
|
133
|
+
@mx_or_a_servers ||= Resolv::DNS.open do |dns|
|
123
134
|
(mx_servers.any? && mx_servers) ||
|
124
135
|
dns.getresources(address.domain, Resolv::DNS::Resource::IN::A)
|
125
136
|
end
|
@@ -5,7 +5,7 @@ require "active_model/validations"
|
|
5
5
|
module ValidEmail2
|
6
6
|
class EmailValidator < ActiveModel::EachValidator
|
7
7
|
def default_options
|
8
|
-
{ regex: true, disposable: false, mx: false, disallow_subaddressing: false, multiple: false }
|
8
|
+
{ regex: true, disposable: false, mx: false, strict_mx: false, disallow_subaddressing: false, multiple: false }
|
9
9
|
end
|
10
10
|
|
11
11
|
def validate_each(record, attribute, value)
|
@@ -48,6 +48,10 @@ module ValidEmail2
|
|
48
48
|
if options[:mx]
|
49
49
|
error(record, attribute) && return unless addresses.all?(&:valid_mx?)
|
50
50
|
end
|
51
|
+
|
52
|
+
if options[:strict_mx]
|
53
|
+
error(record, attribute) && return unless addresses.all?(&:valid_strict_mx?)
|
54
|
+
end
|
51
55
|
end
|
52
56
|
|
53
57
|
def error(record, attribute)
|
data/lib/valid_email2/version.rb
CHANGED
data/pull_mailchecker_emails.rb
CHANGED
@@ -8,7 +8,7 @@ require "net/http"
|
|
8
8
|
whitelisted_emails = %w(
|
9
9
|
onet.pl poczta.onet.pl fastmail.fm hushmail.com
|
10
10
|
hush.ai hush.com hushmail.me naver.com qq.com example.com
|
11
|
-
yandex.net gmx.com gmx.es
|
11
|
+
yandex.net gmx.com gmx.es webdesignspecialist.com.au vp.com
|
12
12
|
)
|
13
13
|
|
14
14
|
existing_emails = File.open("config/disposable_email_domains.txt") { |f| f.read.split("\n") }
|
data/spec/valid_email2_spec.rb
CHANGED
@@ -19,6 +19,10 @@ class TestUserMX < TestModel
|
|
19
19
|
validates :email, 'valid_email_2/email': { mx: true }
|
20
20
|
end
|
21
21
|
|
22
|
+
class TestUserStrictMX < TestModel
|
23
|
+
validates :email, 'valid_email_2/email': { strict_mx: true }
|
24
|
+
end
|
25
|
+
|
22
26
|
class TestUserDisallowDisposable < TestModel
|
23
27
|
validates :email, 'valid_email_2/email': { disposable: true }
|
24
28
|
end
|
@@ -253,6 +257,23 @@ describe ValidEmail2 do
|
|
253
257
|
end
|
254
258
|
end
|
255
259
|
|
260
|
+
describe "with strict mx validation" do
|
261
|
+
it "is valid if mx records are found" do
|
262
|
+
user = TestUserStrictMX.new(email: "foo@gmail.com")
|
263
|
+
expect(user.valid?).to be_truthy
|
264
|
+
end
|
265
|
+
|
266
|
+
it "is invalid if A records are found but no mx records are found" do
|
267
|
+
user = TestUserStrictMX.new(email: "foo@ghs.google.com")
|
268
|
+
expect(user.valid?).to be_falsey
|
269
|
+
end
|
270
|
+
|
271
|
+
it "is invalid if no mx records are found" do
|
272
|
+
user = TestUserStrictMX.new(email: "foo@subdomain.gmail.com")
|
273
|
+
expect(user.valid?).to be_falsey
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
256
277
|
describe "with dotted validation" do
|
257
278
|
it "is valid when address does not contain dots" do
|
258
279
|
user = TestUserDotted.new(email: "johndoe@gmail.com")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valid_email2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micke Lisinge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '0'
|
159
159
|
requirements: []
|
160
|
-
rubygems_version: 3.1.
|
160
|
+
rubygems_version: 3.1.4
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: ActiveModel validation for email. Including MX lookup and disposable email
|