hash_keys_sanitizer 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68938f9ab219d28c8e29c587c57bfa8998ca9ce5
|
4
|
+
data.tar.gz: d9cb21072845d4367169fdc9ddfa86fc65f207b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be6b036229c03bd2d91663516ebd68c24a1bfb8b253f272675084169c24ba7b11f9df4baeb22b1c7b3c564c5b83d18e04c932891b5941cb6b458df7678f30dc3
|
7
|
+
data.tar.gz: c665b10f1a807516d249513066ea0e848c92d5999ffb6b43101425006bf002ae2fd86725ea41f31d56781f01110529d6cd9f4bcdbdb41671c8b0e4865a8ccd8c
|
@@ -28,8 +28,10 @@ class HashKeysSanitizer
|
|
28
28
|
# { address: [:street, :city, ...] }
|
29
29
|
elsif entry.is_a?(Hash)
|
30
30
|
key = entry.keys.first.to_sym
|
31
|
-
|
32
|
-
|
31
|
+
if raw_parameters.has_key?(key)
|
32
|
+
kept_params[key] ||= {}
|
33
|
+
sanitize_nesting(kept_params[key], entry.values.first, raw_parameters[key])
|
34
|
+
end
|
33
35
|
else
|
34
36
|
raise HashKeysSanitizerError, "Unsupported whitelist entry type #{entry.class}: #{entry.inspect}"
|
35
37
|
end
|
@@ -19,6 +19,11 @@ describe HashKeysSanitizer do
|
|
19
19
|
expect(filtered_params).to eq(name: 'John', address: { street: "John Street", email: { type: 'job' } })
|
20
20
|
end
|
21
21
|
|
22
|
+
it "filters out all hash keys if none matches" do
|
23
|
+
filtered_params = sanitizer.sanitize(foo: 'John', bars: { xy: "John Street" })
|
24
|
+
expect(filtered_params).to eq({})
|
25
|
+
end
|
26
|
+
|
22
27
|
it "does not modify original hash" do
|
23
28
|
filtered_params = sanitizer.sanitize(raw_hash)
|
24
29
|
expect(raw_hash).to eq(name: 'John', unknown: 'dummy', address: { street: "John Street", unknown: "BANG",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_keys_sanitizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Baustert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|