mini_defender 0.5.5 → 0.5.7

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: 530d1373078938df751149e2e02ccad634c4575e636374fc532a523ad0a1a7d0
4
- data.tar.gz: 56410958ff3a856d9fdee8f001346bfe6b4851c4b7c7c4df45adb4f0922754bd
3
+ metadata.gz: 42cffd5eb5cd6e4e6735ac05f335fd0d2cb856430b666893e8b4477c5ac65262
4
+ data.tar.gz: 2af39ecec258011f4f4f7d20b447fcf984d239a27b6db4d4f26acd185bfe1031
5
5
  SHA512:
6
- metadata.gz: 13715f920cc17e0374f87b02be2d613b9789e8c0f09b648e055ec8580408dfa0133e698c518019b9f8bd69b4b9f772d942e1556b025e701b53bad3b9a71d9efc
7
- data.tar.gz: bf50307441669882e6dac6688985cf41f4214f6f5ea3506c396ef742465b46fe8e8f3e6f320f4bd9e89f59cac9b07b0c67cb9030f703027ee971717fa2ab658a
6
+ metadata.gz: 06c12dedec9bcf79df20573f7de5553f5b5eeff4f00f6c39132f3f4b901009b4903403821f1fbec828ef49f65c6d0e5e0843eef06ee7db06163505055ebc47bc
7
+ data.tar.gz: af62aaeffc7200becfeec360a4192f0fd184dede43c16f953a1ab0e4ff3b51dc434e22d0744906d3e2e6062511d284eafa739822646285d69220759918bf12b6
@@ -5,6 +5,14 @@ class MiniDefender::Rules::Iban < MiniDefender::Rule
5
5
  'SA' => 24
6
6
  }
7
7
 
8
+ REPLACEMENTS = {
9
+ 'A' => '10', 'B' => '11', 'C' => '12', 'D' => '13', 'E' => '14', 'F' => '15',
10
+ 'G' => '16', 'H' => '17', 'I' => '18', 'J' => '19', 'K' => '20', 'L' => '21',
11
+ 'M' => '22', 'N' => '23', 'O' => '24', 'P' => '25', 'Q' => '26', 'R' => '27',
12
+ 'S' => '28', 'T' => '29', 'U' => '30', 'V' => '31', 'W' => '32', 'X' => '33',
13
+ 'Y' => '34', 'Z' => '35'
14
+ }
15
+
8
16
  def self.signature
9
17
  'iban'
10
18
  end
@@ -19,8 +27,9 @@ class MiniDefender::Rules::Iban < MiniDefender::Rule
19
27
  end
20
28
 
21
29
  def valid_checksum?(iban)
22
- iban = "#{iban[4..]}#{letter_code(iban[0])}#{letter_code(iban[1])}#{iban[2..3]}".to_i
23
- iban % 97 === 1
30
+ iban = "#{iban[4..]}#{iban[0..1]}#{iban[2..3]}"
31
+ iban = iban.gsub(Regexp.union(REPLACEMENTS.keys), REPLACEMENTS)
32
+ iban.to_i % 97 === 1
24
33
  end
25
34
 
26
35
  def valid_length?(iban)
@@ -30,11 +39,4 @@ class MiniDefender::Rules::Iban < MiniDefender::Rule
30
39
  def message(attribute, value, validator)
31
40
  "The value should be a valid IBAN."
32
41
  end
33
-
34
- private
35
-
36
- def letter_code(letter)
37
- # letter is assumed to be an upcase ASCII alphabet letter (A-Z)
38
- letter.ord - 55
39
- end
40
42
  end
@@ -66,7 +66,7 @@ module MiniDefender
66
66
  coerced = rule.coerce(coerced)
67
67
  force_coerce = rule.force_coerce?
68
68
  else
69
- @errors[k] << rule.error_message(k, value, self)
69
+ @errors[k] << rule.error_message(k, coerced, self)
70
70
  end
71
71
  end
72
72
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniDefender
4
- VERSION = "0.5.5"
4
+ VERSION = "0.5.7"
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.5.5
4
+ version: 0.5.7
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-01-24 00:00:00.000000000 Z
11
+ date: 2024-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport