thumblemonks-inquisition 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 1
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 0
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
- if cleansed_attr_readers.include?(attribute.to_sym)
25
- HTML5libSanitize.sanitize_html(read_attribute_without_cleansing(attribute))
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
- read_attribute_without_cleansing(attribute)
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
- write_attribute_without_cleansing(attribute, HTML5libSanitize.sanitize_html(value))
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
@@ -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.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-27 00:00:00 -07:00
12
+ date: 2009-03-31 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15