rails-html-sanitizer 1.7.1 → 1.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +39 -0
- data/README.md +3 -2
- data/lib/rails/html/sanitizer/version.rb +1 -1
- data/lib/rails/html/sanitizer.rb +5 -4
- data/lib/rails/html/scrubbers.rb +2 -14
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c54afd99a374f11c67eb4b1c8ff543d30bd3ca66781a8fa2452719d781c6a07e
|
|
4
|
+
data.tar.gz: 324612d662c1dba47139fba7e1b976384bdc3a616b0d51bf6779d9b343fad2e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df37a5efc973fbe8d95f53dc98f08590bf8454f5d0f2d4e0d549aba63181ca0d83ef541b9a451f0c074ce487d7d4bc6eb6c517a4df6d675015caa55fe3468d42
|
|
7
|
+
data.tar.gz: b70b403bb0f4ca342387ca91d454b2efc94da30c2dcc653853a6f2070ca05cbf1c832853022e6fb91bafb672b753e45c1b44d9d84ab3f67af2a41235d55f5f0c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
## next / unreleased
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## v1.7.2 / 2026-11-02
|
|
5
|
+
|
|
6
|
+
* Deciding whether an SVG `href` or `xlink:href` is a local reference no longer takes quadratic time.
|
|
7
|
+
|
|
8
|
+
`PermitScrubber` matched the attribute value against a pattern that rescanned the value's
|
|
9
|
+
whitespace run from every line start, so an all-whitespace value took seconds to scrub. Only
|
|
10
|
+
Ruby 3.1 and earlier are affected, because Ruby 3.2 introduced linear-time regexp matching.
|
|
11
|
+
Through `PermitScrubber`, applications are only affected if the allowed tags are overridden to
|
|
12
|
+
include an SVG reference element such as `use`; the default configuration is not affected.
|
|
13
|
+
|
|
14
|
+
This change addresses GHSA-cpgf-5mjf-73p7. `PermitScrubber` now applies the html5lib attribute
|
|
15
|
+
value rules by calling `Loofah::HTML5::Scrub.scrub_attribute_value` rather than carrying its own
|
|
16
|
+
copy. The minimum Loofah dependency is now `~> 2.25, >= 2.25.3`.
|
|
17
|
+
|
|
18
|
+
*Mike Dalessio*
|
|
19
|
+
|
|
20
|
+
* rails-html-sanitizer now requires Ruby >= 3.2, because Loofah 2.25.3 requires it.
|
|
21
|
+
|
|
22
|
+
The `1.6.x` and `1.5.x` release branches no longer receive security updates. Every Rails release
|
|
23
|
+
in security support accepts rails-html-sanitizer 1.7 and requires Ruby >= 3.2.
|
|
24
|
+
|
|
25
|
+
*Mike Dalessio*
|
|
26
|
+
|
|
27
|
+
* `SafeListSanitizer` no longer shares a `PermitScrubber` across calls.
|
|
28
|
+
|
|
29
|
+
Previously one sanitizer instance reused a single `PermitScrubber`, assigning its `tags` and
|
|
30
|
+
`attributes` on every call. Action View memoizes one sanitizer per helper module, so two
|
|
31
|
+
concurrent `sanitize` calls with different `tags:` or `attributes:` options could interleave and
|
|
32
|
+
one call could be scrubbed with the other call's allowlist. Each call now builds its own
|
|
33
|
+
`PermitScrubber`.
|
|
34
|
+
|
|
35
|
+
This change addresses GHSA-h7wh-q2qr-458c.
|
|
36
|
+
|
|
37
|
+
*Mike Dalessio*
|
|
38
|
+
|
|
39
|
+
|
|
1
40
|
## v1.7.1 / 2026-07-15
|
|
2
41
|
|
|
3
42
|
* SVG reference elements now restrict both `href` and `xlink:href` to local references.
|
data/README.md
CHANGED
|
@@ -234,8 +234,9 @@ Or install it yourself as:
|
|
|
234
234
|
|
|
235
235
|
| branch | ruby support | actively maintained | security support |
|
|
236
236
|
|--------|--------------|---------------------|----------------------------------------|
|
|
237
|
-
| 1.
|
|
238
|
-
| 1.
|
|
237
|
+
| 1.7.x | >= 3.2 | yes | yes |
|
|
238
|
+
| 1.6.x | >= 2.7 | no | no |
|
|
239
|
+
| 1.5.x | >= 2.5 | no | no |
|
|
239
240
|
| 1.4.x | >= 1.8.7 | no | no |
|
|
240
241
|
|
|
241
242
|
|
data/lib/rails/html/sanitizer.rb
CHANGED
|
@@ -154,7 +154,7 @@ module Rails
|
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
def initialize(prune: false)
|
|
157
|
-
@
|
|
157
|
+
@prune = prune
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
def scrub(fragment, options = {})
|
|
@@ -162,9 +162,10 @@ module Rails
|
|
|
162
162
|
# No duck typing, Loofah ensures subclass of Loofah::Scrubber
|
|
163
163
|
fragment.scrub!(scrubber)
|
|
164
164
|
elsif allowed_tags(options) || allowed_attributes(options)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
permit_scrubber = PermitScrubber.new(prune: @prune)
|
|
166
|
+
permit_scrubber.tags = allowed_tags(options)
|
|
167
|
+
permit_scrubber.attributes = allowed_attributes(options)
|
|
168
|
+
fragment.scrub!(permit_scrubber)
|
|
168
169
|
else
|
|
169
170
|
fragment.scrub!(:strip)
|
|
170
171
|
end
|
data/lib/rails/html/scrubbers.rb
CHANGED
|
@@ -160,21 +160,9 @@ module Rails
|
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
def scrub_attribute(node, attr_node)
|
|
163
|
-
attr_name =
|
|
164
|
-
"#{attr_node.namespace.prefix}:#{attr_node.node_name}"
|
|
165
|
-
else
|
|
166
|
-
attr_node.node_name
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
return if Loofah::HTML5::SafeList::ATTR_VAL_IS_URI.include?(attr_name) && Loofah::HTML5::Scrub.scrub_uri_attribute(attr_node)
|
|
163
|
+
attr_name = Loofah::HTML5::Scrub.prefixed_attribute_name(attr_node)
|
|
170
164
|
|
|
171
|
-
if Loofah::HTML5::
|
|
172
|
-
Loofah::HTML5::Scrub.scrub_attribute_that_allows_local_ref(attr_node)
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
if Loofah::HTML5::SafeList::SVG_ALLOW_LOCAL_HREF.include?(node.name) && Loofah::HTML5::SafeList::SVG_HREF_ATTRIBUTES.include?(attr_name) && attr_node.value =~ /^\s*[^#\s].*/m
|
|
176
|
-
attr_node.remove
|
|
177
|
-
end
|
|
165
|
+
return if Loofah::HTML5::Scrub.scrub_attribute_value(node, attr_node, attr_name)
|
|
178
166
|
|
|
179
167
|
node.remove_attribute(attr_node.name) if attr_name == "src" && attr_node.value !~ /[^[:space:]]/
|
|
180
168
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-html-sanitizer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.7.
|
|
4
|
+
version: 1.7.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rafael Mendonça França
|
|
@@ -20,7 +20,7 @@ dependencies:
|
|
|
20
20
|
version: '2.25'
|
|
21
21
|
- - ">="
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: 2.25.
|
|
23
|
+
version: 2.25.3
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -30,7 +30,7 @@ dependencies:
|
|
|
30
30
|
version: '2.25'
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 2.25.
|
|
33
|
+
version: 2.25.3
|
|
34
34
|
- !ruby/object:Gem::Dependency
|
|
35
35
|
name: nokogiri
|
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -120,9 +120,9 @@ licenses:
|
|
|
120
120
|
- MIT
|
|
121
121
|
metadata:
|
|
122
122
|
bug_tracker_uri: https://github.com/rails/rails-html-sanitizer/issues
|
|
123
|
-
changelog_uri: https://github.com/rails/rails-html-sanitizer/blob/v1.7.
|
|
124
|
-
documentation_uri: https://www.rubydoc.info/gems/rails-html-sanitizer/1.7.
|
|
125
|
-
source_code_uri: https://github.com/rails/rails-html-sanitizer/tree/v1.7.
|
|
123
|
+
changelog_uri: https://github.com/rails/rails-html-sanitizer/blob/v1.7.2/CHANGELOG.md
|
|
124
|
+
documentation_uri: https://www.rubydoc.info/gems/rails-html-sanitizer/1.7.2
|
|
125
|
+
source_code_uri: https://github.com/rails/rails-html-sanitizer/tree/v1.7.2
|
|
126
126
|
rdoc_options: []
|
|
127
127
|
require_paths:
|
|
128
128
|
- lib
|
|
@@ -130,14 +130,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
130
130
|
requirements:
|
|
131
131
|
- - ">="
|
|
132
132
|
- !ruby/object:Gem::Version
|
|
133
|
-
version: 2.
|
|
133
|
+
version: 3.2.0
|
|
134
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
requirements:
|
|
136
136
|
- - ">="
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
138
|
version: '0'
|
|
139
139
|
requirements: []
|
|
140
|
-
rubygems_version: 4.0.
|
|
140
|
+
rubygems_version: 4.0.20
|
|
141
141
|
specification_version: 4
|
|
142
142
|
summary: This gem is responsible to sanitize HTML fragments in Rails applications.
|
|
143
143
|
test_files: []
|