valid_email2 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3e4a4d583c6ad8a5e3758c5dcb287616283dec67992ee006168697b80b092d8
4
- data.tar.gz: 14a322e79fbe29504b89a25f5cab6667ed61e82379f35f440ea1c6f93c36dd66
3
+ metadata.gz: b11e62f82282c1cc81c9698a17a44af5d2a0baec3dc9a1f147e8b9f6201885cd
4
+ data.tar.gz: 24b9024326e7f3ad965802c320901f2ecbd42cfcfc7c0b06e757f73767a6ae92
5
5
  SHA512:
6
- metadata.gz: 58de91a219767f5f27a5d8edd7d9eaa6a8cf65c614f00ea687acbf383b45d98158f5208f7dcd46f4d4a5ff7295ae28700dfa10c922707c50d8f460ea2257f53e
7
- data.tar.gz: 9069d8f4b4f002e4464433daa648457400ff90c844bec3613305920d87964bdcb4124af4a5cb36b68d0bdfeb53937f9ffb990370a788e8848f7065fc149c136d
6
+ metadata.gz: cbb94d6b281464231ef30464b775fcbe1d404a8651105b2fe4b488182bc3cdcce9b2140d0a24431db7570c302c85e353f16e4f4444cd4edda009645a64f54ed4
7
+ data.tar.gz: f5783382e56e570a02dd5abb0e7190d4f4e457a5b47e523bd21ddc4eab51fac7680811e2913e56e1db9ee1593f4c368c7f594558227ce635252c1a1e731a8484
@@ -1,3 +1,22 @@
1
+ ## Version 3.3.0
2
+ * Allow multiple addresses separated by comma (https://github.com/micke/valid_email2/pull/156)
3
+ * Make prohibited_domain_characters_regex changeable (https://github.com/micke/valid_email2/pull/157)
4
+
5
+ ## Version 3.2.5
6
+ * Remove false positives
7
+ * Pull new domains
8
+
9
+ ## Version 3.2.4
10
+ * Remove false positives
11
+
12
+ ## Version 3.2.3
13
+ * Disallow backtick (\`) in domain
14
+ * https://github.com/micke/valid_email2/pull/152
15
+ * https://github.com/micke/valid_email2/pull/151
16
+
17
+ ## Version 3.2.2
18
+ * Disallow quote (') in domain
19
+
1
20
  ## Version 3.2.1
2
21
  * Fix loading of blacklisted domains
3
22
 
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Validate emails with the help of the `mail` gem instead of some clunky regexp.
6
6
  Aditionally validate that the domain has a MX record.
7
- Optionally validate against a static [list of disposable email services](config/disposable_email_domains.yml).
7
+ Optionally validate against a static [list of disposable email services](config/disposable_email_domains.txt).
8
8
  Optionally validate that the email is not subaddressed ([RFC5233](https://tools.ietf.org/html/rfc5233)).
9
9
 
10
10
  ### Why?
@@ -83,6 +83,11 @@ To validate create your own custom message:
83
83
  validates :email, 'valid_email_2/email': { message: "is not a valid email" }
84
84
  ```
85
85
 
86
+ To allow multiple addresses separated by comma:
87
+ ```ruby
88
+ validates :email, 'valid_email_2/email': { multiple: true }
89
+ ```
90
+
86
91
  All together:
87
92
  ```ruby
88
93
  validates :email, 'valid_email_2/email': { mx: true, disposable: true, disallow_subaddressing: true}
@@ -4181,6 +4181,9 @@ awahal0vk1o7gbyzf0.ml
4181
4181
  awahal0vk1o7gbyzf0.tk
4182
4182
  awatum.de
4183
4183
  awca.eu
4184
+ awdrt.com
4185
+ awdrt.net
4186
+ awdrt.org
4184
4187
  aweather.ru
4185
4188
  aweightlossguide.com
4186
4189
  awemail.com
@@ -4672,6 +4675,7 @@ beaniemania.net
4672
4675
  beanlignt.com
4673
4676
  bearegone.pro
4674
4677
  bearsarefuzzy.com
4678
+ beastmail.email
4675
4679
  beastrapleaks.blogspot.com
4676
4680
  beatelse.com
4677
4681
  beats-rock.com
@@ -7862,6 +7866,7 @@ cungmuachungnhom.com
7862
7866
  cungsuyngam.com
7863
7867
  cungtam.com
7864
7868
  cuoiz.com
7869
+ cuoly.com
7865
7870
  cuongvumarketingseo.com
7866
7871
  cupf6mdhtujxytdcoxh.cf
7867
7872
  cupf6mdhtujxytdcoxh.ga
@@ -9768,7 +9773,6 @@ edu.auction
9768
9773
  edu.dmtc.dev
9769
9774
  edu.hstu.eu.org
9770
9775
  edu.my
9771
- edu.sg
9772
9776
  eduanswer.ru
9773
9777
  education.eu
9774
9778
  educationleaders-ksa.com
@@ -10118,6 +10122,7 @@ emailme.win
10118
10122
  emailmenow.info
10119
10123
  emailmiser.com
10120
10124
  emailmobile.net
10125
+ emailmonkey.club
10121
10126
  emailmynn.com
10122
10127
  emailmysr.com
10123
10128
  emailna.co
@@ -10347,6 +10352,7 @@ eo-z.com
10347
10352
  eoffice.top
10348
10353
  eomail.com
10349
10354
  eonmech.com
10355
+ eoopy.com
10350
10356
  eorbs.com
10351
10357
  eos2mail.com
10352
10358
  eotoplenie.ru
@@ -11396,6 +11402,8 @@ fitnessjockey.org
11396
11402
  fitnessmojo.org
11397
11403
  fitnessreviewsonline.com
11398
11404
  fitnesszbyszko.pl
11405
+ fitschool.be
11406
+ fitschool.space
11399
11407
  fittinggeeks.pl
11400
11408
  fitzgeraldforjudge.com
11401
11409
  five-club.com
@@ -12822,10 +12830,8 @@ gmmx.com
12822
12830
  gmojl.com
12823
12831
  gmsdfhail.com
12824
12832
  gmssail.com
12825
- gmx.com
12826
12833
  gmx.dns-cloud.net
12827
12834
  gmx.dnsabr.com
12828
- gmx.es
12829
12835
  gmx.fr.nf
12830
12836
  gmx1mail.top
12831
12837
  gmxip8vet5glx2n9ld.cf
@@ -15034,6 +15040,7 @@ inboxmail.world
15034
15040
  inboxmails.co
15035
15041
  inboxmails.net
15036
15042
  inboxproxy.com
15043
+ inboxsecure.info
15037
15044
  inboxstore.me
15038
15045
  incarnal.pl
15039
15046
  incestry.co.uk
@@ -15177,6 +15184,7 @@ instaindofree.com
15177
15184
  instaku-media.com
15178
15185
  instambox.com
15179
15186
  instance-email.com
15187
+ instant-email.org
15180
15188
  instant-job.com
15181
15189
  instant-mail.de
15182
15190
  instantblingmail.info
@@ -17263,6 +17271,7 @@ labas.com
17263
17271
  labetteraverouge.at
17264
17272
  labfortyone.tk
17265
17273
  labo.ch
17274
+ labomail.pro
17266
17275
  laboratortehnicadentara.ro
17267
17276
  laboriously.com
17268
17277
  labum.com
@@ -18795,6 +18804,7 @@ mailbox92.biz
18795
18804
  mailboxheaven.info
18796
18805
  mailboxint.info
18797
18806
  mailboxlife.net
18807
+ mailboxok.club
18798
18808
  mailboxonline.org
18799
18809
  mailboxrental.org
18800
18810
  mailboxxx.net
@@ -18984,6 +18994,7 @@ mailloading.com
18984
18994
  maillotdefoot.com
18985
18995
  mailly.xyz
18986
18996
  mailman.com
18997
+ mailmanbox.com
18987
18998
  mailmassa.info
18988
18999
  mailmate.com
18989
19000
  mailme.gq
@@ -19024,6 +19035,7 @@ mailnowapp.com
19024
19035
  mailnull.com
19025
19036
  mailo.cf
19026
19037
  mailo.tk
19038
+ mailolo.info
19027
19039
  mailonaut.com
19028
19040
  mailondandan.com
19029
19041
  mailone.es.vu
@@ -19054,6 +19066,7 @@ mailproxy.gm9.com
19054
19066
  mailpts.com
19055
19067
  mailpuppet.tk
19056
19068
  mailquack.com
19069
+ mailquack.info
19057
19070
  mailraccoon.com
19058
19071
  mailrard01.ga
19059
19072
  mailrazer.com
@@ -21561,6 +21574,7 @@ nomail.ga
21561
21574
  nomail.net
21562
21575
  nomail.nodns.xyz
21563
21576
  nomail.pw
21577
+ nomail.top
21564
21578
  nomail.xl.cx
21565
21579
  nomail2me.com
21566
21580
  nomailthankyou.com
@@ -23839,6 +23853,7 @@ privateclosets.com
23839
23853
  privateinvest.me
23840
23854
  privatemail.in
23841
23855
  privatemailinator.nl
23856
+ privateme.site
23842
23857
  privatemitel.cf
23843
23858
  privatemitel.ml
23844
23859
  privatesent.tk
@@ -23914,6 +23929,7 @@ prolagu.pro
23914
23929
  prolifepowerup.com
23915
23930
  promail.net
23916
23931
  promail.site
23932
+ promailerapp.com
23917
23933
  promails.xyz
23918
23934
  promdresses-short.com
23919
23935
  promenadahotel.pl
@@ -26757,6 +26773,7 @@ simple-mail-server.bid
26757
26773
  simplebox.email
26758
26774
  simpleemail.in
26759
26775
  simpleemail.info
26776
+ simpleinboxer.site
26760
26777
  simpleitsecurity.info
26761
26778
  simplemail.in
26762
26779
  simplemail.top
@@ -28469,6 +28486,7 @@ tempemailaddress.com
28469
28486
  tempemails.io
28470
28487
  tempinbox.co.uk
28471
28488
  tempinbox.com
28489
+ tempinbox.xyz
28472
28490
  tempm.cf
28473
28491
  tempm.com
28474
28492
  tempm.ga
@@ -29585,6 +29603,9 @@ tsukushiakihito.gq
29585
29603
  tt2dx90.com
29586
29604
  ttbbc.com
29587
29605
  ttdfytdd.ml
29606
+ ttirv.com
29607
+ ttirv.net
29608
+ ttirv.org
29588
29609
  ttoubdzlowecm7i2ua8.cf
29589
29610
  ttoubdzlowecm7i2ua8.ga
29590
29611
  ttoubdzlowecm7i2ua8.gq
@@ -30251,6 +30272,7 @@ url.gen.in
30251
30272
  urleur.com
30252
30273
  urltc.com
30253
30274
  urlwave.org
30275
+ urmailman.com
30254
30276
  urodzinydlaadzieci.pl
30255
30277
  uroetueptriwe.cz.cc
30256
30278
  uroid.com
@@ -32774,7 +32796,6 @@ yammyshop.com
32774
32796
  yandere.cu.cc
32775
32797
  yandex.ca
32776
32798
  yandex.comx.cf
32777
- yandex.net
32778
32799
  yandexmail.cf
32779
32800
  yandexmail.ga
32780
32801
  yandexmail.gq
@@ -6,10 +6,18 @@ module ValidEmail2
6
6
  class Address
7
7
  attr_accessor :address
8
8
 
9
- PROHIBITED_DOMAIN_CHARACTERS_REGEX = /[+!_\/\s]/
9
+ PROHIBITED_DOMAIN_CHARACTERS_REGEX = /[+!_\/\s'`]/
10
10
  DEFAULT_RECIPIENT_DELIMITER = '+'.freeze
11
11
  DOT_DELIMITER = '.'.freeze
12
12
 
13
+ def self.prohibited_domain_characters_regex
14
+ @prohibited_domain_characters_regex ||= PROHIBITED_DOMAIN_CHARACTERS_REGEX
15
+ end
16
+
17
+ def self.prohibited_domain_characters_regex=(val)
18
+ @prohibited_domain_characters_regex = val
19
+ end
20
+
13
21
  def initialize(address)
14
22
  @parse_error = false
15
23
  @raw_address = address
@@ -30,7 +38,7 @@ module ValidEmail2
30
38
  if address.domain && address.address == @raw_address
31
39
  domain = address.domain
32
40
 
33
- domain !~ PROHIBITED_DOMAIN_CHARACTERS_REGEX &&
41
+ domain !~ self.class.prohibited_domain_characters_regex &&
34
42
  # Domain needs to have at least one dot
35
43
  domain =~ /\./ &&
36
44
  # Domain may not have two consecutive dots
@@ -5,43 +5,44 @@ 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 }
8
+ { regex: true, disposable: false, mx: false, disallow_subaddressing: false, multiple: false }
9
9
  end
10
10
 
11
11
  def validate_each(record, attribute, value)
12
12
  return unless value.present?
13
13
  options = default_options.merge(self.options)
14
14
 
15
- address = ValidEmail2::Address.new(value)
15
+ value_spitted = options[:multiple] ? value.split(',').map(&:strip) : [value]
16
+ addresses = value_spitted.map { |v| ValidEmail2::Address.new(v) }
16
17
 
17
- error(record, attribute) && return unless address.valid?
18
+ error(record, attribute) && return unless addresses.all?(&:valid?)
18
19
 
19
20
  if options[:disallow_dotted]
20
- error(record, attribute) && return if address.dotted?
21
+ error(record, attribute) && return if addresses.any?(&:dotted?)
21
22
  end
22
23
 
23
24
  if options[:disallow_subaddressing]
24
- error(record, attribute) && return if address.subaddressed?
25
+ error(record, attribute) && return if addresses.any?(&:subaddressed?)
25
26
  end
26
27
 
27
28
  if options[:disposable]
28
- error(record, attribute) && return if address.disposable?
29
+ error(record, attribute) && return if addresses.any?(&:disposable?)
29
30
  end
30
31
 
31
32
  if options[:disposable_domain]
32
- error(record, attribute) && return if address.disposable_domain?
33
+ error(record, attribute) && return if addresses.any?(&:disposable_domain?)
33
34
  end
34
35
 
35
36
  if options[:disposable_with_whitelist]
36
- error(record, attribute) && return if address.disposable? && !address.whitelisted?
37
+ error(record, attribute) && return if addresses.any? { |address| address.disposable? && !address.whitelisted? }
37
38
  end
38
39
 
39
40
  if options[:blacklist]
40
- error(record, attribute) && return if address.blacklisted?
41
+ error(record, attribute) && return if addresses.any?(&:blacklisted?)
41
42
  end
42
43
 
43
44
  if options[:mx]
44
- error(record, attribute) && return unless address.valid_mx?
45
+ error(record, attribute) && return unless addresses.all?(&:valid_mx?)
45
46
  end
46
47
  end
47
48
 
@@ -1,3 +1,3 @@
1
1
  module ValidEmail2
2
- VERSION = "3.2.1"
2
+ VERSION = "3.3.0"
3
3
  end
@@ -8,6 +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
12
  )
12
13
 
13
14
  existing_emails = File.open("config/disposable_email_domains.txt") { |f| f.read.split("\n") }
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "spec_helper"
4
+ require "fileutils"
4
5
 
5
6
  class TestUser < TestModel
6
7
  validates :email, 'valid_email_2/email': true
@@ -38,6 +39,10 @@ class TestUserMessage < TestModel
38
39
  validates :email, 'valid_email_2/email': { message: "custom message" }
39
40
  end
40
41
 
42
+ class TestUserMultiple < TestModel
43
+ validates :email, 'valid_email_2/email': { multiple: true }
44
+ end
45
+
41
46
  describe ValidEmail2 do
42
47
 
43
48
  let(:disposable_domain) { ValidEmail2.disposable_emails.first }
@@ -59,8 +64,8 @@ describe ValidEmail2 do
59
64
  expect(user.valid?).to be_falsey
60
65
  end
61
66
 
62
- it "is invalid if email contains invalid characters" do
63
- %w[+ _ !].each do |invalid_character|
67
+ %w[+ _ ! / \ ' `].each do |invalid_character|
68
+ it "is invalid if email contains a \"#{invalid_character}\" character" do
64
69
  user = TestUser.new(email: "foo@google#{invalid_character}yahoo.com")
65
70
  expect(user.valid?).to be_falsey
66
71
  end
@@ -243,6 +248,20 @@ describe ValidEmail2 do
243
248
  end
244
249
  end
245
250
 
251
+ describe "with multiple addresses" do
252
+ it "tests each address for it's own" do
253
+ user = TestUserMultiple.new(email: "foo@gmail.com, bar@gmail.com")
254
+ expect(user.valid?).to be_truthy
255
+ end
256
+
257
+ context 'when one address is invalid' do
258
+ it "fails for all" do
259
+ user = TestUserMultiple.new(email: "foo@gmail.com, bar@123")
260
+ expect(user.valid?).to be_falsey
261
+ end
262
+ end
263
+ end
264
+
246
265
  describe "#dotted?" do
247
266
  it "is true when address local part contains a dot delimiter ('.')" do
248
267
  email = ValidEmail2::Address.new("john.doe@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.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micke Lisinge
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-26 00:00:00.000000000 Z
11
+ date: 2020-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,7 +127,7 @@ homepage: https://github.com/micke/valid_email2
127
127
  licenses:
128
128
  - MIT
129
129
  metadata: {}
130
- post_install_message:
130
+ post_install_message:
131
131
  rdoc_options: []
132
132
  require_paths:
133
133
  - lib
@@ -142,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
- rubygems_version: 3.0.3
146
- signing_key:
145
+ rubygems_version: 3.1.2
146
+ signing_key:
147
147
  specification_version: 4
148
148
  summary: ActiveModel validation for email. Including MX lookup and disposable email
149
149
  blacklist