sanitize_model_attributes 0.0.5 → 0.0.6
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: 75eb387490b5f093275db37d0a93246fc9521e67
|
4
|
+
data.tar.gz: 2136438a78bf9c3505712ad6782f0f4639a0787a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03afd16138a392b3a8c6de7ab0300cfebcd3e383f5d1798e340ca735e6d719e0f34c01dff7d241f207f5ad418997923daf10807ee961dc230636d817af59b6cf
|
7
|
+
data.tar.gz: 0991d808fccac688f835079a7d5fd46d977c7111c7edf39971711e43646158e014df68fabc595b2e419c333be99efbe782b102c270c601e4009e52198b82d564
|
@@ -13,7 +13,8 @@ module SanitizeModelAttributes
|
|
13
13
|
args.each do |attribute_name|
|
14
14
|
self.class_eval do
|
15
15
|
define_method "#{attribute_name}=".to_sym do |attribute_value|
|
16
|
-
|
16
|
+
attribute_value = Sanitize.fragment(attribute_value) unless attribute_value.frozen?
|
17
|
+
write_attribute attribute_name.to_sym, attribute_value
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -31,4 +31,15 @@ class TestString < Minitest::Test
|
|
31
31
|
instance.name = '<strong>hogehoge</strong>'
|
32
32
|
assert_equal 'hogehoge', instance.instance_variable_get(:@name)
|
33
33
|
end
|
34
|
+
|
35
|
+
def test_to_skip_frozen_string
|
36
|
+
instance = @klass.new
|
37
|
+
|
38
|
+
def instance.write_attribute(name, value)
|
39
|
+
instance_variable_set("@#{name}".to_sym, value)
|
40
|
+
end
|
41
|
+
|
42
|
+
instance.name = '<strong>hogehoge</strong>'.freeze
|
43
|
+
assert_equal '<strong>hogehoge</strong>', instance.instance_variable_get(:@name)
|
44
|
+
end
|
34
45
|
end
|