exceptional 2.0.25 → 2.0.26
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.
@@ -28,8 +28,27 @@ module Exceptional
|
|
28
28
|
}
|
29
29
|
end
|
30
30
|
|
31
|
+
def filter_hash(keys_to_filter, hash)
|
32
|
+
if keys_to_filter.is_a?(Array) && !keys_to_filter.empty?
|
33
|
+
hash.each do |key, value|
|
34
|
+
if value.respond_to?(:to_hash)
|
35
|
+
filter_hash(keys_to_filter, hash[key])
|
36
|
+
elsif key_match?(key, keys_to_filter)
|
37
|
+
hash[key] = "[FILTERED]"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
hash
|
42
|
+
end
|
43
|
+
|
44
|
+
def key_match?(key, keys_to_filter)
|
45
|
+
keys_to_filter.map {|k| k.to_s}.include?(key.to_s)
|
46
|
+
end
|
47
|
+
|
31
48
|
def filter_paramaters(hash)
|
32
|
-
if @
|
49
|
+
if @request.respond_to?(:env) && @request.env["action_dispatch.parameter_filter"]
|
50
|
+
filter_hash(@request.env["action_dispatch.parameter_filter"], hash)
|
51
|
+
elsif @controller.respond_to?(:filter_parameters)
|
33
52
|
@controller.send(:filter_parameters, hash)
|
34
53
|
else
|
35
54
|
hash
|
data/lib/exceptional/version.rb
CHANGED
@@ -117,6 +117,13 @@ describe Exceptional::ControllerExceptionData, 'with request/controller/params'
|
|
117
117
|
Exceptional::ControllerExceptionData.sanitize_hash(input).should == {'crazy' => [crazy.to_s]}
|
118
118
|
end
|
119
119
|
|
120
|
+
it "filter params specified in env['action_dispatch.parameter_filter']" do
|
121
|
+
@request.stub!(:env).and_return({'SOME_VAR' => 'abc', 'HTTP_CONTENT_TYPE' => 'text/html', 'action_dispatch.parameter_filter' => [:var1]})
|
122
|
+
@request.stub!(:parameters).and_return({'var1' => 'abc'})
|
123
|
+
data = Exceptional::ControllerExceptionData.new(@error, @controller, @request)
|
124
|
+
data.to_hash['request']['parameters'].should == {'var1' => '[FILTERED]'}
|
125
|
+
end
|
126
|
+
|
120
127
|
it "ArgumentError bug with file object" do
|
121
128
|
file = File.new(File.expand_path('../../fixtures/favicon.png',__FILE__))
|
122
129
|
@request.stub!(:parameters).and_return({'something' => file })
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exceptional
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 26
|
10
|
+
version: 2.0.26
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Contrast
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-14 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|