selma 0.4.7-x64-mingw-ucrt → 0.4.9-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/selma/3.1/selma.so +0 -0
- data/lib/selma/3.2/selma.so +0 -0
- data/lib/selma/3.3/selma.so +0 -0
- data/lib/selma/sanitizer/config.rb +2 -2
- data/lib/selma/sanitizer.rb +0 -82
- data/lib/selma/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97875c47d653300217a352fb894366b8a9b408f3c5b20cd54081afd70b55cfb8
|
4
|
+
data.tar.gz: b605e1b84721c4bb8b7d956dfe28be6c0b6eba9f5f38863c3e03a7748ac75e01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea3db3d0e6b04b042ff77f6e509922f5e809e0cc4f05b31b31d6266c3a54af50bf16a7b8274f484860a079b6e720c2758cd62676979568682220c61eea14e610
|
7
|
+
data.tar.gz: 2af918a924fb8397634cb5ff6e25222861ed8fe5cb48d942075a4e5f5ad9be79c0575b50cb74af0145fce2f101b7f93bb1908003260dde8c4aa0713177578acc
|
data/lib/selma/3.1/selma.so
CHANGED
Binary file
|
data/lib/selma/3.2/selma.so
CHANGED
Binary file
|
data/lib/selma/3.3/selma.so
CHANGED
Binary file
|
@@ -28,7 +28,7 @@ module Selma
|
|
28
28
|
raise ArgumentError, "other_config must be a Hash" unless other_config.is_a?(Hash)
|
29
29
|
|
30
30
|
merged = {}
|
31
|
-
keys = Set.new(config.keys + other_config.keys)
|
31
|
+
keys = Set.new(config.keys + other_config.keys).to_a
|
32
32
|
|
33
33
|
keys.each do |key|
|
34
34
|
oldval = config[key]
|
@@ -39,7 +39,7 @@ module Selma
|
|
39
39
|
merged[key] = if oldval.is_a?(Hash) && newval.is_a?(Hash)
|
40
40
|
oldval.empty? ? newval.dup : merge(oldval, newval)
|
41
41
|
elsif newval.is_a?(Array) && key != :transformers
|
42
|
-
Set.new(newval)
|
42
|
+
Set.new(newval).to_a
|
43
43
|
else
|
44
44
|
can_dupe?(newval) ? newval.dup : newval
|
45
45
|
end
|
data/lib/selma/sanitizer.rb
CHANGED
@@ -4,87 +4,5 @@ require "selma/sanitizer/config"
|
|
4
4
|
|
5
5
|
module Selma
|
6
6
|
class Sanitizer
|
7
|
-
ALLOW = 1 << 0
|
8
|
-
ESCAPE_TAGFILTER = (1 << 1)
|
9
|
-
REMOVE_CONTENTS = (1 << 2)
|
10
|
-
WRAP_WHITESPACE = (1 << 3)
|
11
|
-
|
12
|
-
# initialize is in Rust, this just helps manage config setup in Ruby
|
13
|
-
# TODO: could this just become initialize?
|
14
|
-
def setup
|
15
|
-
allow_element(config[:elements] || [])
|
16
|
-
|
17
|
-
(config[:attributes] || {}).each do |element, attrs|
|
18
|
-
allow_attribute(element, attrs)
|
19
|
-
end
|
20
|
-
|
21
|
-
(config[:protocols] || {}).each do |element, protocols|
|
22
|
-
protocols.each do |attribute, pr|
|
23
|
-
allow_protocol(element, attribute, pr)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
remove_contents(config[:remove_contents]) if config.include?(:remove_contents)
|
28
|
-
|
29
|
-
wrap_with_whitespace(config[:whitespace_elements]) if config.include?(:whitespace_elements)
|
30
|
-
|
31
|
-
set_escape_tagfilter(config.fetch(:escape_tagfilter, true))
|
32
|
-
set_allow_comments(config.fetch(:allow_comments, false))
|
33
|
-
set_allow_doctype(config.fetch(:allow_doctype, true))
|
34
|
-
end
|
35
|
-
|
36
|
-
def elements
|
37
|
-
config[:elements]
|
38
|
-
end
|
39
|
-
|
40
|
-
def allow_element(elements)
|
41
|
-
elements.flatten.each { |e| set_flag(e, ALLOW, true) }
|
42
|
-
end
|
43
|
-
|
44
|
-
def disallow_element(elements)
|
45
|
-
elements.flatten.each { |e| set_flag(e, ALLOW, false) }
|
46
|
-
end
|
47
|
-
|
48
|
-
def allow_attribute(element, attrs)
|
49
|
-
attrs.flatten.each { |attr| set_allowed_attribute(element, attr, true) }
|
50
|
-
end
|
51
|
-
|
52
|
-
def require_any_attributes(element, attrs)
|
53
|
-
if attr.empty?
|
54
|
-
set_required_attribute(element, "*", true)
|
55
|
-
else
|
56
|
-
attrs.flatten.each { |attr| set_required_attribute(element, attr, true) }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def disallow_attribute(element, attrs)
|
61
|
-
attrs.flatten.each { |attr| set_allowed_attribute(element, attr, false) }
|
62
|
-
end
|
63
|
-
|
64
|
-
def allow_class(element, *klass)
|
65
|
-
klass.flatten.each { |k| set_allowed_class(element, k, true) }
|
66
|
-
end
|
67
|
-
|
68
|
-
def allow_protocol(element, attr, protos)
|
69
|
-
if protos.is_a?(Array)
|
70
|
-
raise ArgumentError, "`:all` must be passed outside of an array" if protos.include?(:all)
|
71
|
-
else
|
72
|
-
protos = [protos]
|
73
|
-
end
|
74
|
-
|
75
|
-
set_allowed_protocols(element, attr, protos)
|
76
|
-
end
|
77
|
-
|
78
|
-
def remove_contents(elements)
|
79
|
-
if elements.is_a?(TrueClass) || elements.is_a?(FalseClass)
|
80
|
-
set_all_flags(REMOVE_CONTENTS, elements)
|
81
|
-
else
|
82
|
-
elements.flatten.each { |e| set_flag(e, REMOVE_CONTENTS, true) }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def wrap_with_whitespace(elements)
|
87
|
-
elements.flatten.each { |e| set_flag(e, WRAP_WHITESPACE, true) }
|
88
|
-
end
|
89
7
|
end
|
90
8
|
end
|
data/lib/selma/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.9
|
5
5
|
platform: x64-mingw-ucrt
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|