sanitize_rich_text 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sanitize_rich_text/core.rb +4 -12
- data/lib/sanitize_rich_text/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8b861f3ceb942ed880d06a41a5f747f9e01612a
|
4
|
+
data.tar.gz: fef1bc5c0047b1ce95b55e2bd8838eb257398161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3989a52509a6facc10fa5ddd40ddf39f6c9bf7adc9b9f3eb6eba9a81ce024b27309eb3311bfdb211046e497cb0f6929c7e60da414f0e0aa867dfd55fc1312d41
|
7
|
+
data.tar.gz: 6f8a206fa39d639e4875eaed4dc87f9080ac8c9e12a6958475cc8d2c832c47d276d01c70c00acf972d6f4f803a458f0e51f0a7602a306d90b406d5c59bd1340f
|
@@ -8,25 +8,17 @@ module SanitizeRichText
|
|
8
8
|
class_methods do
|
9
9
|
def sanitize_rich_text(attr_name, options = {})
|
10
10
|
define_method("#{attr_name}=") do |value|
|
11
|
+
html_elements = ['a', 'strong', 'b', 'br', 'em', 'sub', 'sup', 'ul', 'ol', 'li', 'p', 'u']
|
12
|
+
html_attributes = { 'a' => ['href', 'target'] }
|
11
13
|
super(
|
12
14
|
Sanitize.fragment(
|
13
15
|
value,
|
14
|
-
elements: options.fetch(:elements, nil) ||
|
15
|
-
attributes: options.fetch(:attributes, nil) ||
|
16
|
+
elements: options.fetch(:elements, nil) || html_elements,
|
17
|
+
attributes: options.fetch(:attributes, nil) || html_attributes,
|
16
18
|
)
|
17
19
|
)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
21
|
-
|
22
|
-
protected
|
23
|
-
|
24
|
-
def elements
|
25
|
-
['a', 'strong', 'b', 'br', 'em', 'sub', 'sup', 'ul', 'ol', 'li', 'p', 'u']
|
26
|
-
end
|
27
|
-
|
28
|
-
def attributes
|
29
|
-
{ 'a' => ['href', 'target'] }
|
30
|
-
end
|
31
23
|
end
|
32
24
|
end
|