validators 3.4.1 → 3.4.2

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: a736f1025396b9890dbee7e6b132b4614171ea40fb40dae7b2328c46041450b0
4
- data.tar.gz: 99b1a2f3ad91b27c2da61e0041e9fc467bdce72e4d4e74ceb9f94966535d8c1d
3
+ metadata.gz: d0f693875b0571922e182c06e57d4710dc698506a3859d943973706a4565fa3a
4
+ data.tar.gz: 36729706a9f37dec4243a16bd7e1a2e77007e07e03077413a78d04fba2607d53
5
5
  SHA512:
6
- metadata.gz: aae5016154a43eb9ce819edb9c89174235bbd1d16999f66b03a27d220f1ee94f22d4fa537cdb5ea860552252ae12ff0595a9a306799c00216eab5676ad6a709d
7
- data.tar.gz: a832a6d26868df4dcf0d53b456318adb79d40d604006bf14ed926ed027407bfbf8023af5257edcf9ca62e9cf6a41a1a77c5cf5f32697a8624ae9db695afe84f5
6
+ metadata.gz: ee2529d3bf6c418fff9f38c104c9f8d3df27121213472ef15b12ae19c37f4dbbeb527b821f1d48b4d803a06810efd1fbb7b3807f3cdec574c76ea1d547840def
7
+ data.tar.gz: 278ff5305f827bf8f097426de34ab0543b57474dc731586b6c278e199b8c7c8ac1499c8d0c875dd54378ab292009a9a8e8bc44f8ea16ba75f317fcdaa9b682eb
data/.rubocop.yml CHANGED
@@ -10,15 +10,6 @@ AllCops:
10
10
  Style/AsciiComments:
11
11
  Enabled: false
12
12
 
13
- Metrics/AbcSize:
14
- Enabled: false
15
-
16
- Metrics/CyclomaticComplexity:
17
- Enabled: false
18
-
19
- Metrics/PerceivedComplexity:
20
- Enabled: false
21
-
22
13
  Style/Alias:
23
14
  Enabled: false
24
15
 
@@ -28,13 +19,5 @@ Layout/LineLength:
28
19
  Style/IfUnlessModifier:
29
20
  Enabled: false
30
21
 
31
- Metrics/MethodLength:
32
- Enabled: false
33
-
34
- Metrics/BlockLength:
35
- Exclude:
36
- - bin/**/*
37
- - "*.gemspec"
38
-
39
22
  Layout/EmptyLinesAroundAttributeAccessor:
40
23
  Enabled: false
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "open-uri"
6
+ require "json"
7
+ require "yaml"
8
+ require "email_data"
9
+ require "aitch"
10
+
11
+ def fetch_nkkollaw
12
+ matchers = YAML.safe_load(Aitch.get("https://github.com/nkkollaw/reserved-subdomains/raw/master/reserved-subdomains.yaml").body).map(&:to_s)
13
+ matchers.map do |matcher|
14
+ next matcher unless matcher.start_with?("/")
15
+
16
+ matcher.gsub(%r{/(.*?)/}) do |_m, _group|
17
+ new_matcher = Regexp.last_match(1).gsub("[0-9]+", "[0-9-]*")
18
+ "/^#{new_matcher}$/"
19
+ end
20
+ end
21
+ end
22
+
23
+ def fetch_mottie
24
+ data = JSON.parse(Aitch.get("https://github.com/Mottie/github-reserved-names/raw/master/oddballs.json").body, symbolize_names: true)
25
+ data.keys.map(&:to_s)
26
+ end
27
+
28
+ def fetch_jedireza
29
+ data = JSON.parse(Aitch.get("https://github.com/jedireza/reserved-subdomains/raw/master/names.json").body, symbolize_names: true)
30
+ data.map(&:to_s)
31
+ end
32
+
33
+ def fetch_mvila
34
+ data = JSON.parse(Aitch.get("https://github.com/mvila/reserved-usernames/raw/master/data.json").body)
35
+ data.map(&:to_s)
36
+ end
37
+
38
+ def fetch_lukes
39
+ data = JSON.parse(Aitch.get("https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes/raw/master/all/all.json").body)
40
+ data.map do |info|
41
+ info["alpha-2"].downcase
42
+ end
43
+ end
44
+
45
+ def fetch_dominicsayers
46
+ %w[
47
+ https://github.com/dominicsayers/reserved_subdomain/raw/master/lib/reserved_subdomain/literals/miscellaneous.txt
48
+ ].each_with_object([]) do |url, buffer|
49
+ data = Aitch.get(url).body.lines
50
+ buffer.push(*data.map(&:chomp))
51
+ end
52
+ end
53
+
54
+ subdomains = []
55
+ subdomains << fetch_nkkollaw
56
+ subdomains << fetch_mottie
57
+ subdomains << fetch_jedireza
58
+ subdomains << fetch_mvila
59
+ subdomains << fetch_lukes
60
+ subdomains << fetch_dominicsayers
61
+ subdomains << ("a".."z").to_a
62
+ subdomains << EmailData.tlds
63
+ subdomains << %w[
64
+ /^db[0-9-]*$/
65
+ /^dc[0-9-]*$/
66
+ /^dev[0-9-]*$/
67
+ /^dns[0-9-]*$/
68
+ /^ftp[0-9-]*$/
69
+ /^host[0-9-]*$/
70
+ /^mail[0-9-]*$/
71
+ /^mx[0-9-]*$/
72
+ /^ns[0-9-]*$/
73
+ /^ntp[0-9-]*$/
74
+ /^server[0-9-]*$/
75
+ /^smtp[0-9-]*$/
76
+ /^static[0-9-]*$/
77
+ /^support[0-9-]*$/
78
+ /^test[0-9-]*$/
79
+ /^vpn[0-9-]*$/
80
+ /^web[0-9-]*$/
81
+ /^www[0-9-]*$/
82
+ /^your.+$/
83
+ /^[0-9-]+$/
84
+ eu
85
+ us
86
+ ]
87
+
88
+ subdomains = subdomains.flatten.map do |subdomain|
89
+ next subdomain if subdomain.start_with?("/")
90
+
91
+ subdomain.gsub(/[-_]/, "")
92
+ end
93
+
94
+ File.open("./data/reserved_subdomains.txt", "w") do |file|
95
+ file << subdomains.flatten.uniq.sort.map(&:downcase).join("\n")
96
+ end
@@ -136,6 +136,7 @@ adult
136
136
  adv
137
137
  advanceautoparts
138
138
  advertising
139
+ advisories
139
140
  ae
140
141
  aecom
141
142
  aeg
@@ -144,7 +145,6 @@ aero
144
145
  aes
145
146
  aetna
146
147
  af
147
- afamilycompany
148
148
  affiliate
149
149
  affiliates
150
150
  afginc
@@ -398,7 +398,6 @@ brother
398
398
  brussels
399
399
  bs
400
400
  bt
401
- budapest
402
401
  bug
403
402
  bugatti
404
403
  bugs
@@ -451,7 +450,6 @@ cars
451
450
  cart
452
451
  casa
453
452
  case
454
- caseih
455
453
  casestudies
456
454
  caseys
457
455
  cash
@@ -472,7 +470,6 @@ cc
472
470
  cd
473
471
  cdn
474
472
  cdw
475
- ceb
476
473
  celanese
477
474
  celgene
478
475
  centene
@@ -743,7 +740,6 @@ drupal
743
740
  dteenergy
744
741
  dtv
745
742
  dubai
746
- duck
747
743
  dukeenergy
748
744
  dunlop
749
745
  dupont
@@ -950,7 +946,6 @@ fs
950
946
  ftp
951
947
  ftr
952
948
  fujitsu
953
- fujixerox
954
949
  fun
955
950
  fund
956
951
  furniture
@@ -1008,7 +1003,6 @@ github
1008
1003
  gives
1009
1004
  giving
1010
1005
  gl
1011
- glade
1012
1006
  glass
1013
1007
  gle
1014
1008
  global
@@ -1230,7 +1224,6 @@ item
1230
1224
  items
1231
1225
  itv
1232
1226
  itw
1233
- iveco
1234
1227
  j
1235
1228
  jabber
1236
1229
  jabil
@@ -1243,7 +1236,6 @@ javanese
1243
1236
  javascript
1244
1237
  jbhunt
1245
1238
  jcb
1246
- jcp
1247
1239
  jcpenney
1248
1240
  je
1249
1241
  jeep
@@ -1292,6 +1284,7 @@ kg
1292
1284
  kh
1293
1285
  ki
1294
1286
  kia
1287
+ kids
1295
1288
  kiewit
1296
1289
  kim
1297
1290
  kimberlyclark
@@ -1397,7 +1390,6 @@ live
1397
1390
  livejournal
1398
1391
  livenation
1399
1392
  living
1400
- lixil
1401
1393
  lj
1402
1394
  lk
1403
1395
  lkqcorp
@@ -1435,7 +1427,6 @@ ltd
1435
1427
  ltda
1436
1428
  lu
1437
1429
  lundbeck
1438
- lupin
1439
1430
  luxe
1440
1431
  luxury
1441
1432
  lv
@@ -1631,7 +1622,6 @@ networkip
1631
1622
  neustar
1632
1623
  new
1633
1624
  newellbrands
1634
- newholland
1635
1625
  newmont
1636
1626
  news
1637
1627
  newscorp
@@ -1709,7 +1699,6 @@ oauth
1709
1699
  oauthclients
1710
1700
  obi
1711
1701
  observer
1712
- off
1713
1702
  offer
1714
1703
  offers
1715
1704
  office
@@ -1732,7 +1721,6 @@ oneok
1732
1721
  ong
1733
1722
  onl
1734
1723
  online
1735
- onyourside
1736
1724
  ooo
1737
1725
  open
1738
1726
  openid
@@ -1924,11 +1912,9 @@ query
1924
1912
  quest
1925
1913
  questdiagnostics
1926
1914
  quintiles
1927
- qvc
1928
1915
  r
1929
1916
  racing
1930
1917
  radio
1931
- raid
1932
1918
  ralphlauren
1933
1919
  random
1934
1920
  ranking
@@ -1999,7 +1985,6 @@ ril
1999
1985
  rio
2000
1986
  rip
2001
1987
  riteaid
2002
- rmit
2003
1988
  ro
2004
1989
  rocher
2005
1990
  rocks
@@ -2071,7 +2056,6 @@ schools
2071
2056
  schule
2072
2057
  schwarz
2073
2058
  science
2074
- scjohnson
2075
2059
  scot
2076
2060
  script
2077
2061
  scripts
@@ -2128,7 +2112,6 @@ shopping
2128
2112
  shouji
2129
2113
  show
2130
2114
  showtime
2131
- shriram
2132
2115
  si
2133
2116
  signin
2134
2117
  signout
@@ -2176,6 +2159,7 @@ southerncompany
2176
2159
  southwest
2177
2160
  soy
2178
2161
  sp
2162
+ spa
2179
2163
  space
2180
2164
  spam
2181
2165
  spanish
@@ -2189,7 +2173,6 @@ spiritaero
2189
2173
  sport
2190
2174
  sports
2191
2175
  spot
2192
- spreadbetting
2193
2176
  sql
2194
2177
  sr
2195
2178
  src
@@ -2262,7 +2245,6 @@ suzuki
2262
2245
  sv
2263
2246
  svn
2264
2247
  swatch
2265
- swiftcover
2266
2248
  swiss
2267
2249
  sx
2268
2250
  sy
@@ -2646,12 +2628,12 @@ xn3bst00m
2646
2628
  xn3ds443g
2647
2629
  xn3e0b707e
2648
2630
  xn3hcrj9c
2649
- xn3oq18vl8pn36a
2650
2631
  xn3pxu8k
2651
2632
  xn42c2d9a
2652
2633
  xn45br5cyl
2653
2634
  xn45brj9c
2654
2635
  xn45q11c
2636
+ xn4dbrk0ce
2655
2637
  xn4gbrim
2656
2638
  xn54b7fta0cc
2657
2639
  xn55qw42g
@@ -13,7 +13,7 @@ module Validators
13
13
 
14
14
  def self.include?(email)
15
15
  mailbox, domain = email.to_s.split("@")
16
- mailbox = mailbox.to_s.gsub(".", "")
16
+ mailbox = mailbox.to_s.delete(".")
17
17
  mailbox = mailbox.gsub(/\+(.+)?\Z/, "")
18
18
 
19
19
  all.include?("#{mailbox}@#{domain}")
data/lib/validators/ip.rb CHANGED
@@ -11,13 +11,13 @@ module Validators
11
11
  # Extracted from Ruby 1.8.7
12
12
  def v6?(addr)
13
13
  # IPv6 (normal)
14
- return true if /\A[\da-f]{1,4}(:[\da-f]{1,4})*\Z/i =~ addr
15
- return true if /\A[\da-f]{1,4}(:[\da-f]{1,4})*::([\da-f]{1,4}(:[\da-f]{1,4})*)?\Z/i =~ addr
16
- return true if /\A::([\da-f]{1,4}(:[\da-f]{1,4})*)?\Z/i =~ addr
14
+ return true if /\A[\da-f]{1,4}(:[\da-f]{1,4})*\Z/i.match?(addr)
15
+ return true if /\A[\da-f]{1,4}(:[\da-f]{1,4})*::([\da-f]{1,4}(:[\da-f]{1,4})*)?\Z/i.match?(addr)
16
+ return true if /\A::([\da-f]{1,4}(:[\da-f]{1,4})*)?\Z/i.match?(addr)
17
17
  # IPv6 (IPv4 compat)
18
- return true if /\A[\da-f]{1,4}(:[\da-f]{1,4})*:/i =~ addr && v4?($')
19
- return true if /\A[\da-f]{1,4}(:[\da-f]{1,4})*::([\da-f]{1,4}(:[\da-f]{1,4})*:)?/i =~ addr && v4?($')
20
- return true if /\A::([\da-f]{1,4}(:[\da-f]{1,4})*:)?/i =~ addr && v4?($')
18
+ return true if /\A[\da-f]{1,4}(:[\da-f]{1,4})*:/i =~ addr && v4?(Regexp.last_match.post_match)
19
+ return true if /\A[\da-f]{1,4}(:[\da-f]{1,4})*::([\da-f]{1,4}(:[\da-f]{1,4})*:)?/i =~ addr && v4?(Regexp.last_match.post_match)
20
+ return true if /\A::([\da-f]{1,4}(:[\da-f]{1,4})*:)?/i =~ addr && v4?(Regexp.last_match.post_match)
21
21
 
22
22
  false
23
23
  end
@@ -3,8 +3,8 @@ en:
3
3
  activemodel: &activemodel
4
4
  errors:
5
5
  messages:
6
- disposable_email: "is not allowed (high-bounce email)"
7
6
  disposable_domain: "is not allowed (high-bounce domain)"
7
+ disposable_email: "is not allowed (high-bounce email)"
8
8
  invalid_cnpj: "is not a valid CNPJ"
9
9
  invalid_cpf: "is not a valid CPF"
10
10
  invalid_date: "is not a valid date"
@@ -17,14 +17,15 @@ en:
17
17
  invalid_ipv6_address: "is not a valid IPv6 address"
18
18
  invalid_owner: "is not associated with your user"
19
19
  invalid_ssh_private_key: "is not a valid private SSH key"
20
- invalid_ssh_private_key_bits: "needs to be at least %{required} bits; got %{value} bits instead"
20
+ invalid_ssh_private_key_bits:
21
+ "needs to be at least %{required} bits; got %{value} bits instead"
21
22
  invalid_ssh_private_key_type: "must be a %{value} key"
22
23
  invalid_ssh_public_key: "is not a valid public SSH key"
24
+ invalid_subdomain: "is invalid"
23
25
  invalid_url: "is not a valid address"
26
+ invalid_username: "is invalid"
24
27
  reserved_subdomain: "%{value} is a reserved subdomain"
25
- invalid_subdomain: "is invalid"
26
28
  reserved_username: "%{value} is a reserved username"
27
- invalid_username: "is invalid"
28
29
 
29
30
  activerecord:
30
31
  <<: *activemodel
@@ -3,8 +3,8 @@ pt-BR:
3
3
  activemodel: &activemodel
4
4
  errors:
5
5
  messages:
6
- disposable_email: "não é permitido (e-mail temporário)"
7
6
  disposable_domain: "não é permitido (e-mail temporário)"
7
+ disposable_email: "não é permitido (e-mail temporário)"
8
8
  invalid_cnpj: "não é um CNPJ válido"
9
9
  invalid_cpf: "não é um CPF válido"
10
10
  invalid_date: "não é uma data válida"
@@ -17,11 +17,15 @@ pt-BR:
17
17
  invalid_ipv6_address: "não é um endereço IPv6 válido"
18
18
  invalid_owner: "não está associado ao seu usuário"
19
19
  invalid_ssh_private_key: "não é uma chave privada de SSH válida"
20
- invalid_ssh_private_key_bits: "precisa ter pelo menos %{required} bits; a sua chave tem %{value} bits"
20
+ invalid_ssh_private_key_bits:
21
+ "precisa ter pelo menos %{required} bits; a sua chave tem %{value}
22
+ bits"
21
23
  invalid_ssh_private_key_type: "precisa ser uma chave %{value}"
22
24
  invalid_ssh_public_key: "não é uma chave pública de SSH válida"
25
+ invalid_subdomain: "é inválido"
23
26
  invalid_url: "não parece ser uma URL válida"
24
- reserved_hostname: "%{value} é um hostname reservado"
27
+ invalid_username: "não é válido"
28
+ reserved_subdomain: "%{value} é um subdomínio reservado"
25
29
  reserved_username: "%{value} é nome de usuário reservado"
26
30
 
27
31
  activerecord:
@@ -40,9 +40,10 @@ module ActiveModel
40
40
  record.__send__(option) if record.respond_to?(option)
41
41
  end
42
42
 
43
- if date.is_a?(Time)
43
+ case date
44
+ when Time
44
45
  value = value.to_time
45
- elsif date.is_a?(Date)
46
+ when Date
46
47
  value = value.to_date
47
48
  end
48
49
 
@@ -19,8 +19,8 @@ module ActiveModel
19
19
  end
20
20
 
21
21
  def validate_email_format(record, attribute, value, options)
22
- return if value.to_s =~ Validators::EMAIL_FORMAT
23
- return if value.to_s =~ Validators::MICROSOFT_EMAIL_FORMAT
22
+ return if Validators::EMAIL_FORMAT.match?(value.to_s)
23
+ return if Validators::MICROSOFT_EMAIL_FORMAT.match?(value.to_s)
24
24
 
25
25
  record.errors.add(
26
26
  attribute,
@@ -4,7 +4,7 @@ module Validators
4
4
  module Version
5
5
  MAJOR = 3
6
6
  MINOR = 4
7
- PATCH = 1
7
+ PATCH = 2
8
8
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
9
9
  end
10
10
  end
@@ -13,9 +13,7 @@ class DisposableEmailTest < Minitest::Test
13
13
  assert_includes user.errors[:email],
14
14
  I18n.t("activerecord.errors.messages.disposable_domain")
15
15
  end
16
- end
17
16
 
18
- DISPOSABLE_DOMAINS.each do |domain|
19
17
  test "rejects disposable e-mail with subdomain (custom.#{domain})" do
20
18
  User.validates_email_format_of :email
21
19
 
data/validators.gemspec CHANGED
@@ -12,10 +12,10 @@ Gem::Specification.new do |s|
12
12
  s.summary = "Add some nice ActiveModel/ActiveRecord validators."
13
13
  s.description = s.summary
14
14
  s.license = "MIT"
15
- s.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
15
+ s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
16
+ s.metadata = {"rubygems_mfa_required" => "true"}
16
17
 
17
18
  s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`
20
20
  .split("\n")
21
21
  .map {|f| File.basename(f) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-29 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -279,7 +279,8 @@ dependencies:
279
279
  description: Add some nice ActiveModel/ActiveRecord validators.
280
280
  email:
281
281
  - fnando.vieira@gmail.com
282
- executables: []
282
+ executables:
283
+ - sync-reserved-subdomains
283
284
  extensions: []
284
285
  extra_rdoc_files: []
285
286
  files:
@@ -290,6 +291,7 @@ files:
290
291
  - Gemfile
291
292
  - README.md
292
293
  - Rakefile
294
+ - bin/sync-reserved-subdomains
293
295
  - data/reserved_subdomains.txt
294
296
  - lib/validators.rb
295
297
  - lib/validators/constants.rb
@@ -349,7 +351,8 @@ files:
349
351
  homepage: http://rubygems.org/gems/validators
350
352
  licenses:
351
353
  - MIT
352
- metadata: {}
354
+ metadata:
355
+ rubygems_mfa_required: 'true'
353
356
  post_install_message:
354
357
  rdoc_options: []
355
358
  require_paths:
@@ -358,46 +361,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
358
361
  requirements:
359
362
  - - ">="
360
363
  - !ruby/object:Gem::Version
361
- version: 2.3.0
364
+ version: 2.5.0
362
365
  required_rubygems_version: !ruby/object:Gem::Requirement
363
366
  requirements:
364
367
  - - ">="
365
368
  - !ruby/object:Gem::Version
366
369
  version: '0'
367
370
  requirements: []
368
- rubygems_version: 3.1.2
371
+ rubygems_version: 3.3.7
369
372
  signing_key:
370
373
  specification_version: 4
371
374
  summary: Add some nice ActiveModel/ActiveRecord validators.
372
- test_files:
373
- - test/schema.rb
374
- - test/support/dates.rb
375
- - test/support/emails.rb
376
- - test/support/hostnames.rb
377
- - test/support/ips.rb
378
- - test/support/models.rb
379
- - test/support/urls.rb
380
- - test/test_helper.rb
381
- - test/validators/disposable_email_test.rb
382
- - test/validators/ip_test.rb
383
- - test/validators/validates_cnpj_format_of_test.rb
384
- - test/validators/validates_cpf_format_of_test.rb
385
- - test/validators/validates_datetime/after_option_test.rb
386
- - test/validators/validates_datetime/before_option_test.rb
387
- - test/validators/validates_datetime/defaults_test.rb
388
- - test/validators/validates_email_format_of_test.rb
389
- - test/validators/validates_hostname_format_of/with_tld_validation_test.rb
390
- - test/validators/validates_hostname_format_of/without_tld_validation_test.rb
391
- - test/validators/validates_ip_address/ipv4_test.rb
392
- - test/validators/validates_ip_address/ipv6_test.rb
393
- - test/validators/validates_ip_address_test.rb
394
- - test/validators/validates_ownership_of_test.rb
395
- - test/validators/validates_ssh_private_key/bits_test.rb
396
- - test/validators/validates_ssh_private_key/common_test.rb
397
- - test/validators/validates_ssh_private_key/dsa_test.rb
398
- - test/validators/validates_ssh_private_key/rsa_test.rb
399
- - test/validators/validates_ssh_public_key_test.rb
400
- - test/validators/validates_subdomain_test.rb
401
- - test/validators/validates_url_format_of/with_tld_validation_test.rb
402
- - test/validators/validates_url_format_of/without_tld_validation_test.rb
403
- - test/validators/validates_username_test.rb
375
+ test_files: []