valid_email2 4.0.5 → 5.0.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 +9 -0
- data/config/disposable_email_domains.txt +15634 -3
- data/lib/valid_email2/address.rb +6 -0
- data/lib/valid_email2/email_validator.rb +1 -1
- data/lib/valid_email2/version.rb +1 -1
- data/pull_mailchecker_emails.rb +1 -1
- data/spec/valid_email2_spec.rb +10 -0
- metadata +2 -2
data/lib/valid_email2/address.rb
CHANGED
@@ -91,12 +91,14 @@ module ValidEmail2
|
|
91
91
|
|
92
92
|
def valid_mx?
|
93
93
|
return false unless valid?
|
94
|
+
return false if null_mx?
|
94
95
|
|
95
96
|
mx_or_a_servers.any?
|
96
97
|
end
|
97
98
|
|
98
99
|
def valid_strict_mx?
|
99
100
|
return false unless valid?
|
101
|
+
return false if null_mx?
|
100
102
|
|
101
103
|
mx_servers.any?
|
102
104
|
end
|
@@ -138,6 +140,10 @@ module ValidEmail2
|
|
138
140
|
end
|
139
141
|
end
|
140
142
|
|
143
|
+
def null_mx?
|
144
|
+
mx_servers.length == 1 && mx_servers.first.preference == 0 && mx_servers.first.exchange.length == 0
|
145
|
+
end
|
146
|
+
|
141
147
|
def mx_or_a_servers
|
142
148
|
@mx_or_a_servers ||= Resolv::DNS.open do |dns|
|
143
149
|
dns.timeouts = @dns_timeout
|
@@ -5,7 +5,7 @@ require "active_model/validations"
|
|
5
5
|
module ValidEmail2
|
6
6
|
class EmailValidator < ActiveModel::EachValidator
|
7
7
|
def default_options
|
8
|
-
{
|
8
|
+
{ disposable: false, mx: false, strict_mx: false, disallow_subaddressing: false, multiple: false, dns_timeout: 5 }
|
9
9
|
end
|
10
10
|
|
11
11
|
def validate_each(record, attribute, value)
|
data/lib/valid_email2/version.rb
CHANGED
data/pull_mailchecker_emails.rb
CHANGED
@@ -9,7 +9,7 @@ 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
11
|
yandex.net gmx.com gmx.es webdesignspecialist.com.au vp.com
|
12
|
-
onit.com asics.com freemail.hu 139.com mail2world.com
|
12
|
+
onit.com asics.com freemail.hu 139.com mail2world.com slmail.me
|
13
13
|
)
|
14
14
|
|
15
15
|
existing_emails = File.open("config/disposable_email_domains.txt") { |f| f.read.split("\n") }
|
data/spec/valid_email2_spec.rb
CHANGED
@@ -255,6 +255,11 @@ describe ValidEmail2 do
|
|
255
255
|
user = TestUserMX.new(email: "foo@subdomain.gmail.com")
|
256
256
|
expect(user.valid?).to be_falsey
|
257
257
|
end
|
258
|
+
|
259
|
+
it "is invalid if a null mx is found" do
|
260
|
+
user = TestUserMX.new(email: "foo@gmail.de")
|
261
|
+
expect(user.valid?).to be_falsey
|
262
|
+
end
|
258
263
|
end
|
259
264
|
|
260
265
|
describe "with strict mx validation" do
|
@@ -272,6 +277,11 @@ describe ValidEmail2 do
|
|
272
277
|
user = TestUserStrictMX.new(email: "foo@subdomain.gmail.com")
|
273
278
|
expect(user.valid?).to be_falsey
|
274
279
|
end
|
280
|
+
|
281
|
+
it "is invalid if a null mx is found" do
|
282
|
+
user = TestUserStrictMX.new(email: "foo@gmail.de")
|
283
|
+
expect(user.valid?).to be_falsey
|
284
|
+
end
|
275
285
|
end
|
276
286
|
|
277
287
|
describe "with dotted validation" do
|
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:
|
4
|
+
version: 5.0.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: 2023-
|
11
|
+
date: 2023-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|