valid_email2 4.0.6 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal:true
2
2
 
3
3
  module ValidEmail2
4
- VERSION = "4.0.6"
4
+ VERSION = "5.0.0"
5
5
  end
@@ -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.0.6
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-03-24 00:00:00.000000000 Z
11
+ date: 2023-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler