loofah 2.4.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of loofah might be problematic. Click here for more details.

@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ module Loofah
3
+ # The version of Loofah you are using
4
+ VERSION = "2.9.0"
5
+ end
@@ -13,7 +13,7 @@ module Loofah
13
13
  # constructor. Applications should use Loofah.fragment to
14
14
  # parse a fragment.
15
15
  #
16
- def parse tags
16
+ def parse(tags)
17
17
  doc = Loofah::XML::Document.new
18
18
  doc.encoding = tags.encoding.name if tags.respond_to?(:encoding)
19
19
  self.new(doc, tags)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loofah
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-11-25 00:00:00.000000000 Z
12
+ date: 2021-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -45,28 +45,28 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '12.3'
48
+ version: '13.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '12.3'
55
+ version: '13.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: minitest
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '2.2'
62
+ version: '5.14'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '2.2'
69
+ version: '5.14'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rr
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -87,98 +87,42 @@ dependencies:
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 2.2.0
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: 2.2.0
98
- - !ruby/object:Gem::Dependency
99
- name: hoe-gemspec
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: '1.0'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '1.0'
112
- - !ruby/object:Gem::Dependency
113
- name: hoe-debugging
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - "~>"
117
- - !ruby/object:Gem::Version
118
- version: '2.0'
90
+ version: '2.2'
119
91
  type: :development
120
92
  prerelease: false
121
93
  version_requirements: !ruby/object:Gem::Requirement
122
94
  requirements:
123
95
  - - "~>"
124
96
  - !ruby/object:Gem::Version
125
- version: '2.0'
97
+ version: '2.2'
126
98
  - !ruby/object:Gem::Dependency
127
- name: hoe-bundler
99
+ name: concourse
128
100
  requirement: !ruby/object:Gem::Requirement
129
101
  requirements:
130
102
  - - "~>"
131
103
  - !ruby/object:Gem::Version
132
- version: '1.5'
104
+ version: '0.33'
133
105
  type: :development
134
106
  prerelease: false
135
107
  version_requirements: !ruby/object:Gem::Requirement
136
108
  requirements:
137
109
  - - "~>"
138
110
  - !ruby/object:Gem::Version
139
- version: '1.5'
111
+ version: '0.33'
140
112
  - !ruby/object:Gem::Dependency
141
- name: hoe-git
113
+ name: rubocop
142
114
  requirement: !ruby/object:Gem::Requirement
143
115
  requirements:
144
116
  - - "~>"
145
117
  - !ruby/object:Gem::Version
146
- version: '1.6'
118
+ version: '1.1'
147
119
  type: :development
148
120
  prerelease: false
149
121
  version_requirements: !ruby/object:Gem::Requirement
150
122
  requirements:
151
123
  - - "~>"
152
124
  - !ruby/object:Gem::Version
153
- version: '1.6'
154
- - !ruby/object:Gem::Dependency
155
- name: concourse
156
- requirement: !ruby/object:Gem::Requirement
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- version: 0.26.0
161
- type: :development
162
- prerelease: false
163
- version_requirements: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- version: 0.26.0
168
- - !ruby/object:Gem::Dependency
169
- name: rubocop
170
- requirement: !ruby/object:Gem::Requirement
171
- requirements:
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- version: 0.76.0
175
- type: :development
176
- prerelease: false
177
- version_requirements: !ruby/object:Gem::Requirement
178
- requirements:
179
- - - ">="
180
- - !ruby/object:Gem::Version
181
- version: 0.76.0
125
+ version: '1.1'
182
126
  - !ruby/object:Gem::Dependency
183
127
  name: rdoc
184
128
  requirement: !ruby/object:Gem::Requirement
@@ -200,19 +144,19 @@ dependencies:
200
144
  - !ruby/object:Gem::Version
201
145
  version: '7'
202
146
  - !ruby/object:Gem::Dependency
203
- name: hoe
147
+ name: hoe-markdown
204
148
  requirement: !ruby/object:Gem::Requirement
205
149
  requirements:
206
150
  - - "~>"
207
151
  - !ruby/object:Gem::Version
208
- version: '3.20'
152
+ version: '1.3'
209
153
  type: :development
210
154
  prerelease: false
211
155
  version_requirements: !ruby/object:Gem::Requirement
212
156
  requirements:
213
157
  - - "~>"
214
158
  - !ruby/object:Gem::Version
215
- version: '3.20'
159
+ version: '1.3'
216
160
  description: |-
217
161
  Loofah is a general library for manipulating and transforming HTML/XML documents and fragments, built on top of Nokogiri.
218
162
 
@@ -224,25 +168,12 @@ email:
224
168
  - bryan@brynary.com
225
169
  executables: []
226
170
  extensions: []
227
- extra_rdoc_files:
228
- - CHANGELOG.md
229
- - MIT-LICENSE.txt
230
- - Manifest.txt
231
- - README.md
232
- - SECURITY.md
171
+ extra_rdoc_files: []
233
172
  files:
234
- - ".gemtest"
235
173
  - CHANGELOG.md
236
- - Gemfile
237
174
  - MIT-LICENSE.txt
238
- - Manifest.txt
239
175
  - README.md
240
- - Rakefile
241
176
  - SECURITY.md
242
- - benchmark/benchmark.rb
243
- - benchmark/fragment.html
244
- - benchmark/helper.rb
245
- - benchmark/www.slashdot.com.html
246
177
  - lib/loofah.rb
247
178
  - lib/loofah/elements.rb
248
179
  - lib/loofah/helpers.rb
@@ -255,32 +186,20 @@ files:
255
186
  - lib/loofah/metahelpers.rb
256
187
  - lib/loofah/scrubber.rb
257
188
  - lib/loofah/scrubbers.rb
189
+ - lib/loofah/version.rb
258
190
  - lib/loofah/xml/document.rb
259
191
  - lib/loofah/xml/document_fragment.rb
260
- - test/assets/msword.html
261
- - test/assets/testdata_sanitizer_tests1.dat
262
- - test/helper.rb
263
- - test/html5/test_sanitizer.rb
264
- - test/html5/test_scrub.rb
265
- - test/integration/test_ad_hoc.rb
266
- - test/integration/test_helpers.rb
267
- - test/integration/test_html.rb
268
- - test/integration/test_scrubbers.rb
269
- - test/integration/test_xml.rb
270
- - test/unit/test_api.rb
271
- - test/unit/test_encoding.rb
272
- - test/unit/test_helpers.rb
273
- - test/unit/test_scrubber.rb
274
- - test/unit/test_scrubbers.rb
275
192
  homepage: https://github.com/flavorjones/loofah
276
193
  licenses:
277
194
  - MIT
278
195
  metadata:
279
196
  homepage_uri: https://github.com/flavorjones/loofah
197
+ source_code_uri: https://github.com/flavorjones/loofah
198
+ bug_tracker_uri: https://github.com/flavorjones/loofah/issues
199
+ changelog_uri: https://github.com/flavorjones/loofah/blob/master/CHANGELOG.md
200
+ documentation_uri: https://www.rubydoc.info/gems/loofah/
280
201
  post_install_message:
281
- rdoc_options:
282
- - "--main"
283
- - README.md
202
+ rdoc_options: []
284
203
  require_paths:
285
204
  - lib
286
205
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -294,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
294
213
  - !ruby/object:Gem::Version
295
214
  version: '0'
296
215
  requirements: []
297
- rubygems_version: 3.0.3
216
+ rubygems_version: 3.1.4
298
217
  signing_key:
299
218
  specification_version: 4
300
219
  summary: Loofah is a general library for manipulating and transforming HTML/XML documents
data/.gemtest DELETED
File without changes
data/Gemfile DELETED
@@ -1,23 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- # DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
4
-
5
- source "https://rubygems.org/"
6
-
7
- gem "nokogiri", ">=1.5.9"
8
- gem "crass", "~>1.0.2"
9
-
10
- gem "rake", "~>12.3", :group => [:development, :test]
11
- gem "minitest", "~>2.2", :group => [:development, :test]
12
- gem "rr", "~>1.2.0", :group => [:development, :test]
13
- gem "json", "~>2.2.0", :group => [:development, :test]
14
- gem "hoe-gemspec", "~>1.0", :group => [:development, :test]
15
- gem "hoe-debugging", "~>2.0", :group => [:development, :test]
16
- gem "hoe-bundler", "~>1.5", :group => [:development, :test]
17
- gem "hoe-git", "~>1.6", :group => [:development, :test]
18
- gem "concourse", ">=0.26.0", :group => [:development, :test]
19
- gem "rubocop", ">=0.76.0", :group => [:development, :test]
20
- gem "rdoc", ">=4.0", "<7", :group => [:development, :test]
21
- gem "hoe", "~>3.20", :group => [:development, :test]
22
-
23
- # vim: syntax=ruby
@@ -1,41 +0,0 @@
1
- .gemtest
2
- CHANGELOG.md
3
- Gemfile
4
- MIT-LICENSE.txt
5
- Manifest.txt
6
- README.md
7
- Rakefile
8
- SECURITY.md
9
- benchmark/benchmark.rb
10
- benchmark/fragment.html
11
- benchmark/helper.rb
12
- benchmark/www.slashdot.com.html
13
- lib/loofah.rb
14
- lib/loofah/elements.rb
15
- lib/loofah/helpers.rb
16
- lib/loofah/html/document.rb
17
- lib/loofah/html/document_fragment.rb
18
- lib/loofah/html5/libxml2_workarounds.rb
19
- lib/loofah/html5/safelist.rb
20
- lib/loofah/html5/scrub.rb
21
- lib/loofah/instance_methods.rb
22
- lib/loofah/metahelpers.rb
23
- lib/loofah/scrubber.rb
24
- lib/loofah/scrubbers.rb
25
- lib/loofah/xml/document.rb
26
- lib/loofah/xml/document_fragment.rb
27
- test/assets/msword.html
28
- test/assets/testdata_sanitizer_tests1.dat
29
- test/helper.rb
30
- test/html5/test_sanitizer.rb
31
- test/html5/test_scrub.rb
32
- test/integration/test_ad_hoc.rb
33
- test/integration/test_helpers.rb
34
- test/integration/test_html.rb
35
- test/integration/test_scrubbers.rb
36
- test/integration/test_xml.rb
37
- test/unit/test_api.rb
38
- test/unit/test_encoding.rb
39
- test/unit/test_helpers.rb
40
- test/unit/test_scrubber.rb
41
- test/unit/test_scrubbers.rb
data/Rakefile DELETED
@@ -1,91 +0,0 @@
1
- require "rubygems"
2
- require "hoe"
3
- require "concourse"
4
-
5
- Hoe.plugin :git
6
- Hoe.plugin :gemspec
7
- Hoe.plugin :bundler
8
- Hoe.plugin :debugging
9
-
10
- Hoe.spec "loofah" do
11
- developer "Mike Dalessio", "mike.dalessio@gmail.com"
12
- developer "Bryan Helmkamp", "bryan@brynary.com"
13
-
14
- self.extra_rdoc_files = FileList["*.md"]
15
- self.history_file = "CHANGELOG.md"
16
- self.readme_file = "README.md"
17
- self.license "MIT"
18
-
19
- extra_deps << ["nokogiri", ">=1.5.9"]
20
- extra_deps << ["crass", "~> 1.0.2"]
21
-
22
- extra_dev_deps << ["rake", "~> 12.3"]
23
- extra_dev_deps << ["minitest", "~>2.2"]
24
- extra_dev_deps << ["rr", "~>1.2.0"]
25
- extra_dev_deps << ["json", "~> 2.2.0"]
26
- extra_dev_deps << ["hoe-gemspec", "~> 1.0"]
27
- extra_dev_deps << ["hoe-debugging", "~> 2.0"]
28
- extra_dev_deps << ["hoe-bundler", "~> 1.5"]
29
- extra_dev_deps << ["hoe-git", "~> 1.6"]
30
- extra_dev_deps << ["concourse", ">=0.26.0"]
31
- extra_dev_deps << ["rubocop", ">=0.76.0"]
32
- end
33
-
34
- task :gemspec do
35
- system %q(rake debug_gem | grep -v "^\(in " > loofah.gemspec)
36
- end
37
-
38
- task :redocs => :fix_css
39
- task :docs => :fix_css
40
- task :fix_css do
41
- better_css = <<-EOT
42
- .method-description pre {
43
- margin : 1em 0 ;
44
- }
45
-
46
- .method-description ul {
47
- padding : .5em 0 .5em 2em ;
48
- }
49
-
50
- .method-description p {
51
- margin-top : .5em ;
52
- }
53
-
54
- #main ul, div#documentation ul {
55
- list-style-type : disc ! IMPORTANT ;
56
- list-style-position : inside ! IMPORTANT ;
57
- }
58
-
59
- h2 + ul {
60
- margin-top : 1em;
61
- }
62
- EOT
63
- puts "* fixing css"
64
- File.open("doc/rdoc.css", "a") { |f| f.write better_css }
65
- end
66
-
67
- desc "generate and upload docs to rubyforge"
68
- task :doc_upload_to_rubyforge => :docs do
69
- Dir.chdir "doc" do
70
- system "rsync -avz --delete * rubyforge.org:/var/www/gforge-projects/loofah/loofah"
71
- end
72
- end
73
-
74
- desc "generate safelists from W3C specifications"
75
- task :generate_safelists do
76
- load "tasks/generate-safelists"
77
- end
78
-
79
- task :rubocop => [:rubocop_security, :rubocop_frozen_string_literals]
80
- task :rubocop_security do
81
- sh "rubocop lib --only Security"
82
- end
83
- task :rubocop_frozen_string_literals do
84
- sh "rubocop lib --auto-correct --only Style/FrozenStringLiteralComment"
85
- end
86
- Rake::Task[:test].prerequisites << :rubocop
87
-
88
- Concourse.new("loofah", fly_target: "ci") do |c|
89
- c.add_pipeline "loofah", "loofah.yml"
90
- c.add_pipeline "loofah-pr", "loofah-pr.yml"
91
- end
@@ -1,149 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "#{File.dirname(__FILE__)}/helper.rb"
3
-
4
- def compare_scrub_methods
5
- snip = "<div>foo</div><foo>fuxx <b>quux</b></foo><script>i have a chair</script>"
6
- puts "starting with:\n#{snip}"
7
- puts
8
- puts RailsSanitize.new.sanitize(snip) # => Rails.sanitize / scrub!(:prune).to_s
9
- puts Loofah::Helpers.sanitize(snip)
10
- puts "--"
11
- puts RailsSanitize.new.strip_tags(snip) # => Rails.strip_tags / parse().text
12
- puts Loofah::Helpers.strip_tags(snip)
13
- puts "--"
14
- puts Sanitize.clean(snip, Sanitize::Config::RELAXED) # => scrub!(:strip).to_s
15
- puts Loofah.scrub_fragment(snip, :strip).to_s
16
- puts "--"
17
- puts HTML5libSanitize.new.sanitize(snip) # => scrub!(:escape).to_s
18
- puts Loofah.scrub_fragment(snip, :escape).to_s
19
- puts "--"
20
- puts HTMLFilter.new.filter(snip)
21
- puts Loofah.scrub_fragment(snip, :strip).to_s
22
- puts
23
- end
24
-
25
- module TestSet
26
- def test_set options={}
27
- scale = options[:rehearse] ? 10 : 1
28
- puts self.class.name
29
-
30
- n = 100 / scale
31
- puts " Large document, #{BIG_FILE.length} bytes (x#{n})"
32
- bench BIG_FILE, n, false
33
- puts
34
-
35
- n = 1000 / scale
36
- puts " Small fragment, #{FRAGMENT.length} bytes (x#{n})"
37
- bench FRAGMENT, n, true
38
- puts
39
-
40
- n = 10_000 / scale
41
- puts " Text snippet, #{SNIPPET.length} bytes (x#{n})"
42
- bench SNIPPET, n, true
43
- puts
44
- end
45
- end
46
-
47
- class HeadToHead < Measure
48
- end
49
-
50
- class HeadToHeadRailsSanitize < Measure
51
- include TestSet
52
- def bench(content, ntimes, fragment_p)
53
- clear_measure
54
-
55
- measure "Loofah::Helpers.sanitize", ntimes do
56
- Loofah::Helpers.sanitize content
57
- end
58
-
59
- sanitizer = RailsSanitize.new
60
- measure "ActionView sanitize", ntimes do
61
- sanitizer.sanitize(content)
62
- end
63
- end
64
- end
65
-
66
- class HeadToHeadRailsStripTags < Measure
67
- include TestSet
68
- def bench(content, ntimes, fragment_p)
69
- clear_measure
70
-
71
- measure "Loofah::Helpers.strip_tags", ntimes do
72
- Loofah::Helpers.strip_tags content
73
- end
74
-
75
- sanitizer = RailsSanitize.new
76
- measure "ActionView strip_tags", ntimes do
77
- sanitizer.strip_tags(content)
78
- end
79
- end
80
- end
81
-
82
- class HeadToHeadSanitizerSanitize < Measure
83
- include TestSet
84
- def bench(content, ntimes, fragment_p)
85
- clear_measure
86
-
87
- measure "Loofah :strip", ntimes do
88
- if fragment_p
89
- Loofah.scrub_fragment(content, :strip).to_s
90
- else
91
- Loofah.scrub_document(content, :strip).to_s
92
- end
93
- end
94
-
95
- measure "Sanitize.clean", ntimes do
96
- Sanitize.clean(content, Sanitize::Config::RELAXED)
97
- end
98
- end
99
- end
100
-
101
- class HeadToHeadHtml5LibSanitize < Measure
102
- include TestSet
103
- def bench(content, ntimes, fragment_p)
104
- clear_measure
105
-
106
- measure "Loofah :escape", ntimes do
107
- if fragment_p
108
- Loofah.scrub_fragment(content, :escape).to_s
109
- else
110
- Loofah.scrub_document(content, :escape).to_s
111
- end
112
- end
113
-
114
- html5_sanitizer = HTML5libSanitize.new
115
- measure "HTML5lib.sanitize", ntimes do
116
- html5_sanitizer.sanitize(content)
117
- end
118
- end
119
- end
120
-
121
- class HeadToHeadHTMLFilter < Measure
122
- include TestSet
123
- def bench(content, ntimes, fragment_p)
124
- clear_measure
125
-
126
- measure "Loofah::Helpers.sanitize", ntimes do
127
- Loofah::Helpers.sanitize content
128
- end
129
-
130
- sanitizer = HTMLFilter.new
131
- measure "HTMLFilter.filter", ntimes do
132
- sanitizer.filter(content)
133
- end
134
- end
135
- end
136
-
137
- puts "Nokogiri version: #{Nokogiri::VERSION_INFO.inspect}"
138
- puts "Loofah version: #{Loofah::VERSION.inspect}"
139
-
140
- benches = []
141
- benches << HeadToHeadRailsSanitize.new
142
- benches << HeadToHeadRailsStripTags.new
143
- benches << HeadToHeadSanitizerSanitize.new
144
- benches << HeadToHeadHtml5LibSanitize.new
145
- benches << HeadToHeadHTMLFilter.new
146
- puts "---------- rehearsal ----------"
147
- benches.each { |bench| bench.test_set :rehearse => true }
148
- puts "---------- realsies ----------"
149
- benches.each { |bench| bench.test_set }