mini_defender 0.6.0 → 0.6.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: 4afc89ccb1f98c186e927a88b6bd85e9a5194f4dd74c7b45653f8a63feeb8f79
4
- data.tar.gz: 53c21490530615efe4e8ba51c52ac26e2a448f8b3c555af66744dd7c0ce238df
3
+ metadata.gz: 8e0ab4aebfd050f5d3a5560099d9567d6c6bf60e741e36e3bfbc55f8ae84e10d
4
+ data.tar.gz: fd22d8c11ce0b2dbfdaecf36ac48d15fd4a554bab8ab6733d64af267b07edf6d
5
5
  SHA512:
6
- metadata.gz: 9cd0c033f42766e22cb7900b0903d275f3454df9293c553a5f2766154ed73760d7c28cd392ccd051d80bffa4c09027687ef7ca361d375b6f4037d706f26d6435
7
- data.tar.gz: 9a50f0cc9ab6e9cd751d978cd5e37ec48ee2c742f80b5d058af6e82db2c1d2d9fdbf2de155c967fcf5baf1e7079d6fb77ad01dbd7e1d3ed025e0f3a5f0916501
6
+ metadata.gz: 5d7209aae4068a0b26d4f3a3ec3896b4a423aa9c3f201a3534c589359dd4c84de17f764e55f61d2dff5b74387433fbd17a17fef14109127a92ecd6dcebe67dba
7
+ data.tar.gz: 72587c709c155934e3c0c0ef7769f48f938eed2a4dab473a90211fefeb3e215732607cc605c733a4f734f54707df0b00297953b53b925c09e614c35b0f3b926d
@@ -53,7 +53,10 @@ class MiniDefender::Rules::Integer < MiniDefender::Rule
53
53
  return true
54
54
  end
55
55
 
56
- value = value.to_s
56
+ # Remove leading zero so Integer will not treat it as octal
57
+ value = value
58
+ .to_s
59
+ .gsub(/^0+/, '')
57
60
 
58
61
  if @mode == 'relaxed'
59
62
  value = normalize_digits(value)
@@ -7,7 +7,7 @@ module MiniDefender::ValidatesInput
7
7
  data = cleanse_data(params.to_unsafe_hash.deep_stringify_keys)
8
8
  validator = MiniDefender::Validator.new(rules, data)
9
9
  validator.validate!
10
- coerced ? validator.coerced : validator.data
10
+ coerced ? validator.coerced : validator.validated
11
11
  end
12
12
 
13
13
  private
@@ -28,7 +28,7 @@ module MiniDefender
28
28
 
29
29
  # Set default values for missing data key compared to rules
30
30
  data_rules.each do |k, set|
31
- if !@data.key?(k) || @data[k].blank?
31
+ if !@data.key?(k) || missing_value?(@data[k])
32
32
  set.filter{ |r| r.defaults?(self) }.each do |r|
33
33
  @data.merge!({k => r.default_value(self)}.flatten_keys(keep_roots: true))
34
34
  end
@@ -43,7 +43,7 @@ module MiniDefender
43
43
  value_included = true
44
44
  required = rule_set.any? { |r| r.implicit?(self) }
45
45
 
46
- if !@data.key?(k) || @data[k].blank?
46
+ if !@data.key?(k) || missing_value?(@data[k])
47
47
  rule_set.filter{ |r| r.defaults?(self) }.each do |r|
48
48
  @data.merge!({k => r.default_value(self)}.flatten_keys(keep_roots: true))
49
49
  end
@@ -188,5 +188,12 @@ module MiniDefender
188
188
 
189
189
  result
190
190
  end
191
+
192
+ def missing_value?(value)
193
+ value.nil? ||
194
+ value.is_a?(String) && value.strip.empty? ||
195
+ value.is_a?(Hash) && value.empty? ||
196
+ value.is_a?(Array) && value.empty?
197
+ end
191
198
  end
192
199
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniDefender
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_defender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Alhoshaiyan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-12 00:00:00.000000000 Z
11
+ date: 2024-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport