sanitize 4.6.1 → 4.6.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sanitize might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/HISTORY.md +6 -0
- data/lib/sanitize.rb +4 -2
- data/lib/sanitize/transformers/clean_element.rb +1 -1
- data/lib/sanitize/version.rb +1 -1
- data/test/test_clean_element.rb +18 -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: fb775bea4edea52d04bbfca1b95cd52387951da8a257277c2a95e6371d59ef43
|
4
|
+
data.tar.gz: 7a94074ef83e2acecf446bed31fb2de9d5f5a164409481f9af50b5cc85b17608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2c52aea4bd23c99c3cb5e55bcb2e6b63746d02532c19e8c7d5a2bc72e1e3ab571ac03c2aaf7ba4f8d02ab77cdf2be92407069670c3ff9878de6b54675fa5c6e
|
7
|
+
data.tar.gz: d384b9754d718205a5cb2532699d2c71f48d3e4e0854fdbff29cc8bd3f559a4e4b828e6311726605de85906c95d0342b960d67cc9e7426a4c5c00e0eb8b3b946
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Sanitize History
|
2
2
|
|
3
|
+
## 4.6.2 (2018-03-19)
|
4
|
+
|
5
|
+
* Reduced string allocations to optimize memory usage. [@janklimo - #175][175]
|
6
|
+
|
7
|
+
[175]:https://github.com/rgrove/sanitize/pull/175
|
8
|
+
|
3
9
|
## 4.6.1 (2018-03-15)
|
4
10
|
|
5
11
|
* Added support for frozen string literals in Ruby 2.4+.
|
data/lib/sanitize.rb
CHANGED
@@ -198,7 +198,7 @@ class Sanitize
|
|
198
198
|
# the original document didn't actually include a content-type meta tag.
|
199
199
|
replace_meta = !@config[:elements].include?('meta') ||
|
200
200
|
node.xpath('/html/head/meta[@http-equiv]').none? do |meta|
|
201
|
-
meta['http-equiv'].
|
201
|
+
meta['http-equiv'].casecmp('content-type').zero?
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
@@ -217,12 +217,14 @@ class Sanitize
|
|
217
217
|
end
|
218
218
|
|
219
219
|
def transform_node!(node, node_whitelist)
|
220
|
+
node_name = node.name.downcase
|
221
|
+
|
220
222
|
@transformers.each do |transformer|
|
221
223
|
result = transformer.call(
|
222
224
|
:config => @config,
|
223
225
|
:is_whitelisted => node_whitelist.include?(node),
|
224
226
|
:node => node,
|
225
|
-
:node_name =>
|
227
|
+
:node_name => node_name,
|
226
228
|
:node_whitelist => node_whitelist
|
227
229
|
)
|
228
230
|
|
@@ -99,7 +99,7 @@ class Sanitize; module Transformers; class CleanElement
|
|
99
99
|
if @protocols.include?(name) && @protocols[name].include?(attr_name)
|
100
100
|
attr_protocols = @protocols[name][attr_name]
|
101
101
|
|
102
|
-
if attr.value
|
102
|
+
if attr.value =~ REGEX_PROTOCOL
|
103
103
|
attr.unlink unless attr_protocols.include?($1.downcase)
|
104
104
|
else
|
105
105
|
attr.unlink unless attr_protocols.include?(:relative)
|
data/lib/sanitize/version.rb
CHANGED
data/test/test_clean_element.rb
CHANGED
@@ -402,6 +402,23 @@ describe 'Sanitize::Transformers::CleanElement' do
|
|
402
402
|
s.fragment('foo<div>bar</div>baz').must_equal "foo\nbar\nbaz"
|
403
403
|
s.fragment('foo<br>bar<br>baz').must_equal "foo\nbar\nbaz"
|
404
404
|
end
|
405
|
-
end
|
406
405
|
|
406
|
+
it 'handles protocols correctly regardless of case' do
|
407
|
+
input = '<a href="hTTpS://foo.com/">Text</a>'
|
408
|
+
|
409
|
+
Sanitize.fragment(input, {
|
410
|
+
:elements => ['a'],
|
411
|
+
:attributes => {'a' => ['href']},
|
412
|
+
:protocols => {'a' => {'href' => ['https']}}
|
413
|
+
}).must_equal input
|
414
|
+
|
415
|
+
input = '<a href="mailto:someone@example.com?Subject=Hello">Text</a>'
|
416
|
+
|
417
|
+
Sanitize.fragment(input, {
|
418
|
+
:elements => ['a'],
|
419
|
+
:attributes => {'a' => ['href']},
|
420
|
+
:protocols => {'a' => {'href' => ['https']}}
|
421
|
+
}).must_equal "<a>Text</a>"
|
422
|
+
end
|
423
|
+
end
|
407
424
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sanitize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.6.
|
4
|
+
version: 4.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Grove
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: crass
|