credit_card_sanitizer 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/credit_card_sanitizer.rb +8 -5
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91ced181f495dcc979ca941111571ca0480ac27e
|
4
|
+
data.tar.gz: cb74c94b7063871d9a9495711e79745dafa7c4bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffe9c44a8576697ced931554e94b70dc3af49a45c72117fedadfdca3877b48a6a64f9b5df6edf5fa5e91c75e1617868887f6316e5ff797a40cf6984923e6b7c6
|
7
|
+
data.tar.gz: bc35ebcf22f812fb7abd95cb7970a7dfdd503952a18edafb99e345445245defbf09b718c0696852e6eae359c5529a27ac31d6e5e9357757f73ec177555639c7c
|
@@ -38,19 +38,22 @@ class CreditCardSanitizer
|
|
38
38
|
}
|
39
39
|
|
40
40
|
VALID_COMPANY_PREFIXES = Regexp.union(*CARD_COMPANIES.values)
|
41
|
-
EXPIRATION_DATE = /\s(?:0?[1-9]|1[0-2])(?:\/|-)(?:\d{4}|\d{2})(?:\
|
41
|
+
EXPIRATION_DATE = /\s(?:0?[1-9]|1[0-2])(?:\/|-)(?:\d{4}|\d{2})(?:\D|$)/
|
42
42
|
LINE_NOISE_CHAR = /[^\w\n,()&.\/:;<>]/
|
43
43
|
LINE_NOISE = /#{LINE_NOISE_CHAR}{,5}/
|
44
44
|
NONEMPTY_LINE_NOISE = /#{LINE_NOISE_CHAR}{1,5}/
|
45
45
|
SCHEME_OR_PLUS = /((?:+|\+)|(?:[a-zA-Z][\-+.a-zA-Z\d]{,9}):[^\s>]+)/
|
46
46
|
NUMBERS_WITH_LINE_NOISE = /#{SCHEME_OR_PLUS}?\d(?:#{LINE_NOISE}\d){10,30}/
|
47
|
+
HTML_TAGS = /(<\w+(?:(?:\s+\w+(?:\s*=\s*(?:".*?"|'.*?'|[\^'">\s]+))?)+\s*|\s*)>)/
|
48
|
+
SKIP_HTML_TAGS = Regexp.union(HTML_TAGS, NUMBERS_WITH_LINE_NOISE)
|
47
49
|
|
48
50
|
DEFAULT_OPTIONS = {
|
49
51
|
replacement_token: '▇',
|
50
52
|
expose_first: 6,
|
51
53
|
expose_last: 4,
|
52
54
|
use_groupings: false,
|
53
|
-
exclude_tracking_numbers: false
|
55
|
+
exclude_tracking_numbers: false,
|
56
|
+
exclude_html_tags: false
|
54
57
|
}
|
55
58
|
|
56
59
|
attr_reader :settings
|
@@ -92,11 +95,11 @@ class CreditCardSanitizer
|
|
92
95
|
|
93
96
|
text.force_encoding(Encoding::UTF_8)
|
94
97
|
text.scrub!('�')
|
95
|
-
|
98
|
+
regex = options[:exclude_html_tags] ? SKIP_HTML_TAGS : NUMBERS_WITH_LINE_NOISE
|
96
99
|
redacted = nil
|
97
100
|
without_expiration(text) do
|
98
|
-
text.gsub!(
|
99
|
-
next match if $1
|
101
|
+
text.gsub!(regex) do |match|
|
102
|
+
next match if $1 || $2
|
100
103
|
|
101
104
|
candidate = Candidate.new(match, match.tr('^0-9', ''))
|
102
105
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credit_card_sanitizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Chapweske
|
@@ -10,22 +10,8 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-02-
|
13
|
+
date: 2017-02-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: appraisal
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
requirements:
|
19
|
-
- - ">="
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
version: '0'
|
29
15
|
- !ruby/object:Gem::Dependency
|
30
16
|
name: rake
|
31
17
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
124
|
version: '0'
|
139
125
|
requirements: []
|
140
126
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.5.1
|
142
128
|
signing_key:
|
143
129
|
specification_version: 4
|
144
130
|
summary: Credit card sanitizer
|