decontaminator 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1342e0fb22e699e0c0713c095b31231f2d161c46
4
- data.tar.gz: a00919d401c57f5c0aae265842d6bfc8b7f946a2
2
+ SHA256:
3
+ metadata.gz: 9a45d8c542eeecd3b5f303f988a52287cbc086fae6cdb9cba207abc847ac337e
4
+ data.tar.gz: 2718303db20c04bf9a4edebe00945f3ffcee4bd3d6d0597f3e76a75fd1492b22
5
5
  SHA512:
6
- metadata.gz: 9bd7cd77f541ec1176fce4b3e7ca3f00f6fc24c1bd6e813e06212694a1b2c62abba407dfa030883ecda07f41527054018ccd15bceff99b82dc84394ef2c5f802
7
- data.tar.gz: dd07913b676ca10a1230158fdc2aeab321a3fbeff9ee436960b346a34135f4671e61ec2f03bf6da1fd84dc157524371a58bd5d44d3c56998e039068019854bae
6
+ metadata.gz: d88b94cc64ac9adbf2226e8590d7b5e02e5a5c079665989499a1f7efa0b0a703b2c5cb806f1c1cac3e08391b292df1de1347665ad4fa0944f359654880b94de1
7
+ data.tar.gz: 36b788a6f79265112d7e6a9362f8073b05de30bf777cf3a936f1d86927b597d6043ad005ec6dee43727fb330dfb448dab01ca9d21f9ede8ee2d3b9e7d614edc9
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 Altmetric LLP
1
+ Copyright (c) 2015-2018 Altmetric LLP
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Ruby HTML sanitizer based on a lightweight Oga parser.
4
4
 
5
- **Current version:** 1.0.0
5
+ **Current version:** 1.0.1
6
6
 
7
7
  **Supported Ruby versions:** 1.9.3, 2.0, 2.1, 2.2, JRuby 1.7, and Rubinius 2.5
8
8
 
@@ -43,6 +43,6 @@ puts fragment.decontaminate.inspect
43
43
 
44
44
  ## License
45
45
 
46
- Copyright © 2015 Altmetric LLP
46
+ Copyright © 2015-2018 Altmetric LLP
47
47
 
48
48
  Distributed under the [MIT license](https://github.com/altmetric/decontaminator/blob/master/LICENSE.txt).
@@ -52,7 +52,7 @@ module Decontaminator
52
52
 
53
53
  def sanitize(node_set, blacklisted_tags)
54
54
  node_set
55
- .reject { |node| !text?(node) && blacklisted_tags.include?(node.name) }
55
+ .reject { |node| comment?(node) || (!text?(node) && blacklisted_tags.include?(node.name)) }
56
56
  .flat_map { |node| [whitespace(node, :prefix), text(node, blacklisted_tags), whitespace(node, :suffix)] }
57
57
  .join
58
58
  end
@@ -61,6 +61,10 @@ module Decontaminator
61
61
  node.is_a?(Oga::XML::Text)
62
62
  end
63
63
 
64
+ def comment?(node)
65
+ node.is_a?(Oga::XML::Comment)
66
+ end
67
+
64
68
  def whitespace(node, _position)
65
69
  if !text?(node) && WHITESPACE_CONTENT_TAGS.include?(node.name)
66
70
  ' '
@@ -1,3 +1,3 @@
1
1
  module Decontaminator
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -45,5 +45,9 @@ RSpec.describe Decontaminator::Fragment do
45
45
  it 'sanitizes content with blacklisted tags' do
46
46
  expect(described_class.new('<figcaption>Blacklist this</figcaption><p>but not that</p>').decontaminate(blacklist: %w(figcaption))).to eq(' but not that ')
47
47
  end
48
+
49
+ it 'sanitizes content with comments' do
50
+ expect(described_class.new('<div>Hello there<!-- This is a comment --></div>').decontaminate).to eq(' Hello there ')
51
+ end
48
52
  end
49
53
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decontaminator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew MacLeod
8
8
  - Paul Mucur
9
9
  - Jakub Pawlowicz
10
+ - Anna Klimas
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2015-09-16 00:00:00.000000000 Z
14
+ date: 2018-02-01 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: oga
@@ -27,10 +28,7 @@ dependencies:
27
28
  - !ruby/object:Gem::Version
28
29
  version: '1.3'
29
30
  description: Ruby HTML sanitizer based on a lightweight Oga parser.
30
- email:
31
- - matt@matt-m.co.uk
32
- - mudge@mudge.name
33
- - jakub@altmetric.com
31
+ email: support@altmetric.com
34
32
  executables: []
35
33
  extensions: []
36
34
  extra_rdoc_files: []
@@ -61,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
59
  version: '0'
62
60
  requirements: []
63
61
  rubyforge_project:
64
- rubygems_version: 2.4.8
62
+ rubygems_version: 2.7.3
65
63
  signing_key:
66
64
  specification_version: 4
67
65
  summary: HTML sanitizer using lightweight Oga HTML parser.