thumblemonks-inquisition 0.1.1 → 0.1.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.
- data/VERSION.yml +1 -1
- data/lib/inquisition.rb +8 -7
- data/test/inquisition_test.rb +13 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/inquisition.rb
CHANGED
@@ -21,10 +21,11 @@ module Inquisition
|
|
21
21
|
class_inheritable_reader(:cleansed_attr_readers)
|
22
22
|
|
23
23
|
define_method(:read_attribute_with_cleansing) do |attribute|
|
24
|
-
|
25
|
-
|
24
|
+
value = read_attribute_without_cleansing(attribute)
|
25
|
+
if cleansed_attr_readers.include?(attribute.to_sym) && !value.blank?
|
26
|
+
HTML5libSanitize.sanitize_html(value)
|
26
27
|
else
|
27
|
-
|
28
|
+
value
|
28
29
|
end
|
29
30
|
end
|
30
31
|
alias_method_chain :read_attribute, :cleansing
|
@@ -35,11 +36,11 @@ module Inquisition
|
|
35
36
|
class_inheritable_reader(:cleansed_attr_writers)
|
36
37
|
|
37
38
|
define_method(:write_attribute_with_cleansing) do |attribute, value|
|
38
|
-
if cleansed_attr_writers.include?(attribute.to_sym)
|
39
|
-
|
40
|
-
else
|
41
|
-
write_attribute_without_cleansing(attribute, value)
|
39
|
+
if cleansed_attr_writers.include?(attribute.to_sym) && !value.blank?
|
40
|
+
value = HTML5libSanitize.sanitize_html(value)
|
42
41
|
end
|
42
|
+
|
43
|
+
write_attribute_without_cleansing(attribute, value)
|
43
44
|
end
|
44
45
|
alias_method_chain :write_attribute, :cleansing
|
45
46
|
end
|
data/test/inquisition_test.rb
CHANGED
@@ -33,5 +33,18 @@ class InquisitionTest < Test::Unit::TestCase
|
|
33
33
|
private_origin = @whisky.attributes["origin"]
|
34
34
|
assert_equal "<SCRIPT SRC=http://ha.ckers.org/xss.js>Scotland</SCRIPT>", @whisky.origin
|
35
35
|
end
|
36
|
+
|
37
|
+
should "not show pain for setting blank attributes" do
|
38
|
+
@whisky.origin = nil
|
39
|
+
@whisky.name = nil
|
40
|
+
assert_equal nil, @whisky.origin
|
41
|
+
assert_equal nil, @whisky.name
|
42
|
+
end
|
43
|
+
|
44
|
+
should "not show pain for getting blank attributes" do
|
45
|
+
@whisky.update_attributes(:origin => nil, :name => nil)
|
46
|
+
assert_equal nil, @whisky.origin
|
47
|
+
assert_equal nil, @whisky.name
|
48
|
+
end
|
36
49
|
end
|
37
50
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thumblemonks-inquisition
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- toothrot
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-31 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|