valid_email2 3.4.0 → 3.5.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 +5 -0
- data/README.md +7 -1
- data/config/disposable_email_domains.txt +1 -3
- data/lib/valid_email2/address.rb +2 -1
- data/lib/valid_email2/email_validator.rb +4 -0
- data/lib/valid_email2/version.rb +1 -1
- data/spec/valid_email2_spec.rb +37 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85903e3f9f5d0e8222dcc7768e15632eecf4a6008e8a43c2d88549cfa9a140ae
|
4
|
+
data.tar.gz: 2519e54f15012418caa00608301ff19f91640ecf63e9cf88c586afa2d1a0d2d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 811d82babbd7ad076fc077d4dea52074ecf6591926ed6b37b4f6595b614bc46eeacfd944db95ebc577a6cfb36d858009a051eed67e87fa5ce3f06b63c576c8b6
|
7
|
+
data.tar.gz: 653fe9f637840019997480853e5784e4fba055f4d579bce8af3b30e631da8fe86a5074e00564d72444f7b4a1cd0f4d7d829d9928e7c3962d1b612b595cc16545
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## Version 3.5.0
|
2
|
+
* Disallow emails starting with a dot https://github.com/micke/valid_email2/pull/170
|
3
|
+
* Add option to whitelist domains from MX check https://github.com/micke/valid_email2/pull/167
|
4
|
+
* Remove false positives
|
5
|
+
|
1
6
|
## Version 3.4.0
|
2
7
|
* Disallow consecutive dots https://github.com/micke/valid_email2/pull/163
|
3
8
|
* Add andyes.net https://github.com/micke/valid_email2/pull/162
|
data/README.md
CHANGED
@@ -58,11 +58,17 @@ To validate that the domain is not a disposable email (checks domain only, does
|
|
58
58
|
validates :email, 'valid_email_2/email': { disposable_domain: true }
|
59
59
|
```
|
60
60
|
|
61
|
-
To validate that the domain is not a disposable email or a disposable email but whitelisted (under config/whitelisted_email_domains.yml):
|
61
|
+
To validate that the domain is not a disposable email or a disposable email (checks domain and MX server) but whitelisted (under config/whitelisted_email_domains.yml):
|
62
62
|
```ruby
|
63
63
|
validates :email, 'valid_email_2/email': { disposable_with_whitelist: true }
|
64
64
|
```
|
65
65
|
|
66
|
+
To validate that the domain is not a disposable email or a disposable email (checks domain only, does not check MX server) but whitelisted (under config/whitelisted_email_domains.yml):
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
validates :email, 'valid_email_2/email': { disposable_domain_with_whitelist: true }
|
70
|
+
```
|
71
|
+
|
66
72
|
To validate that the domain is not blacklisted (under config/blacklisted_email_domains.yml):
|
67
73
|
```ruby
|
68
74
|
validates :email, 'valid_email_2/email': { blacklist: true }
|
@@ -12324,7 +12324,6 @@ gd6ubc0xilchpozgpg.gq
|
|
12324
12324
|
gd6ubc0xilchpozgpg.ml
|
12325
12325
|
gd6ubc0xilchpozgpg.tk
|
12326
12326
|
gdb.armageddon.org
|
12327
|
-
gdf.it
|
12328
12327
|
gdfretertwer.com
|
12329
12328
|
gdmail.top
|
12330
12329
|
gdradr.com
|
@@ -31027,7 +31026,6 @@ voyagebirmanie.net
|
|
31027
31026
|
voyancegratuite10min.com
|
31028
31027
|
voyeurseite.info
|
31029
31028
|
vozmivtop.ru
|
31030
|
-
vp.com
|
31031
31029
|
vp.ycare.de
|
31032
31030
|
vpanel.ru
|
31033
31031
|
vpc608a0.pl
|
@@ -33700,4 +33698,4 @@ zzv2bfja5.pl
|
|
33700
33698
|
zzz.co
|
33701
33699
|
zzz.com
|
33702
33700
|
zzzmail.pl
|
33703
|
-
zzzzzzzzzzzzz.com
|
33701
|
+
zzzzzzzzzzzzz.com
|
data/lib/valid_email2/address.rb
CHANGED
@@ -37,6 +37,10 @@ module ValidEmail2
|
|
37
37
|
error(record, attribute) && return if addresses.any? { |address| address.disposable? && !address.whitelisted? }
|
38
38
|
end
|
39
39
|
|
40
|
+
if options[:disposable_domain_with_whitelist]
|
41
|
+
error(record, attribute) && return if addresses.any? { |address| address.disposable_domain? && !address.whitelisted? }
|
42
|
+
end
|
43
|
+
|
40
44
|
if options[:blacklist]
|
41
45
|
error(record, attribute) && return if addresses.any?(&:blacklisted?)
|
42
46
|
end
|
data/lib/valid_email2/version.rb
CHANGED
data/spec/valid_email2_spec.rb
CHANGED
@@ -31,6 +31,10 @@ class TestUserDisallowDisposableWithWhitelist < TestModel
|
|
31
31
|
validates :email, 'valid_email_2/email': { disposable_with_whitelist: true }
|
32
32
|
end
|
33
33
|
|
34
|
+
class TestUserDisallowDisposableDomainWithWhitelist < TestModel
|
35
|
+
validates :email, 'valid_email_2/email': { disposable_domain_with_whitelist: true }
|
36
|
+
end
|
37
|
+
|
34
38
|
class TestUserDisallowBlacklisted < TestModel
|
35
39
|
validates :email, 'valid_email_2/email': { blacklist: true }
|
36
40
|
end
|
@@ -92,6 +96,16 @@ describe ValidEmail2 do
|
|
92
96
|
expect(user.valid?).to be_falsey
|
93
97
|
end
|
94
98
|
|
99
|
+
it "is invalid if the address starts with a dot" do
|
100
|
+
user = TestUser.new(email: ".foo@bar.com")
|
101
|
+
expect(user.valid?).to be_falsey
|
102
|
+
end
|
103
|
+
|
104
|
+
it "is invalid if the local part of the address ends with a dot" do
|
105
|
+
user = TestUser.new(email: "foo.@bar.com")
|
106
|
+
expect(user.valid?).to be_falsey
|
107
|
+
end
|
108
|
+
|
95
109
|
it "is invalid if the email contains emoticons" do
|
96
110
|
user = TestUser.new(email: "foo🙈@gmail.com")
|
97
111
|
expect(user.valid?).to be_falsy
|
@@ -170,8 +184,18 @@ describe ValidEmail2 do
|
|
170
184
|
let(:whitelist_domain) { disposable_domain }
|
171
185
|
let(:whitelist_file_path) { "config/whitelisted_email_domains.yml" }
|
172
186
|
|
187
|
+
# Some of the specs below need to explictly set the whitelist var or it
|
188
|
+
# may be cached to an empty set
|
189
|
+
def set_whitelist
|
190
|
+
ValidEmail2.instance_variable_set(
|
191
|
+
:@whitelist,
|
192
|
+
ValidEmail2.send(:load_if_exists, ValidEmail2::WHITELIST_FILE)
|
193
|
+
)
|
194
|
+
end
|
195
|
+
|
173
196
|
after do
|
174
197
|
FileUtils.rm(whitelist_file_path, force: true)
|
198
|
+
set_whitelist
|
175
199
|
end
|
176
200
|
|
177
201
|
it "is invalid if the domain is disposable and not in the whitelist" do
|
@@ -181,9 +205,22 @@ describe ValidEmail2 do
|
|
181
205
|
|
182
206
|
it "is valid if the domain is disposable but in the whitelist" do
|
183
207
|
File.open(whitelist_file_path, "w") { |f| f.write [whitelist_domain].to_yaml }
|
208
|
+
set_whitelist
|
184
209
|
user = TestUserDisallowDisposableWithWhitelist.new(email: "foo@#{whitelist_domain}")
|
210
|
+
expect(user.valid?).to be_truthy
|
211
|
+
end
|
212
|
+
|
213
|
+
it "is invalid if the domain is a disposable_domain and not in the whitelist" do
|
214
|
+
user = TestUserDisallowDisposableDomainWithWhitelist.new(email: "foo@#{whitelist_domain}")
|
185
215
|
expect(user.valid?).to be_falsey
|
186
216
|
end
|
217
|
+
|
218
|
+
it "is valid if the domain is a disposable_domain but in the whitelist" do
|
219
|
+
File.open(whitelist_file_path, "w") { |f| f.write [whitelist_domain].to_yaml }
|
220
|
+
set_whitelist
|
221
|
+
user = TestUserDisallowDisposableDomainWithWhitelist.new(email: "foo@#{whitelist_domain}")
|
222
|
+
expect(user.valid?).to be_truthy
|
223
|
+
end
|
187
224
|
end
|
188
225
|
end
|
189
226
|
|
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.5.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: 2020-
|
11
|
+
date: 2020-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|