loofah 2.2.1 → 2.4.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.

@@ -44,17 +44,17 @@ class UnitTestHelpers < Loofah::TestCase
44
44
  end
45
45
  end
46
46
 
47
- describe "WhiteListSanitizer#sanitize" do
47
+ describe "SafeListSanitizer#sanitize" do
48
48
  it "calls .sanitize" do
49
49
  mock(Loofah::Helpers).sanitize("foobar")
50
- Loofah::Helpers::ActionView::WhiteListSanitizer.new.sanitize "foobar"
50
+ Loofah::Helpers::ActionView::SafeListSanitizer.new.sanitize "foobar"
51
51
  end
52
52
  end
53
53
 
54
- describe "WhiteListSanitizer#sanitize_css" do
54
+ describe "SafeListSanitizer#sanitize_css" do
55
55
  it "calls .sanitize_css" do
56
56
  mock(Loofah::Helpers).sanitize_css("foobar")
57
- Loofah::Helpers::ActionView::WhiteListSanitizer.new.sanitize_css "foobar"
57
+ Loofah::Helpers::ActionView::SafeListSanitizer.new.sanitize_css "foobar"
58
58
  end
59
59
  end
60
60
  end
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.2.1
4
+ version: 2.4.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: 2018-03-19 00:00:00.000000000 Z
12
+ date: 2019-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -43,16 +43,16 @@ dependencies:
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0.8'
48
+ version: '12.3'
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: '0.8'
55
+ version: '12.3'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: minitest
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -85,126 +85,140 @@ dependencies:
85
85
  name: json
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ">="
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '0'
90
+ version: 2.2.0
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ">="
95
+ - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '0'
97
+ version: 2.2.0
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: hoe-gemspec
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ">="
102
+ - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: '0'
104
+ version: '1.0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ">="
109
+ - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: '0'
111
+ version: '1.0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: hoe-debugging
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: '0'
118
+ version: '2.0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ">="
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '0'
125
+ version: '2.0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: hoe-bundler
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - ">="
130
+ - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '0'
132
+ version: '1.5'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ">="
137
+ - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '0'
139
+ version: '1.5'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: hoe-git
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '1.6'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '1.6'
154
+ - !ruby/object:Gem::Dependency
155
+ name: concourse
142
156
  requirement: !ruby/object:Gem::Requirement
143
157
  requirements:
144
158
  - - ">="
145
159
  - !ruby/object:Gem::Version
146
- version: '0'
160
+ version: 0.26.0
147
161
  type: :development
148
162
  prerelease: false
149
163
  version_requirements: !ruby/object:Gem::Requirement
150
164
  requirements:
151
165
  - - ">="
152
166
  - !ruby/object:Gem::Version
153
- version: '0'
167
+ version: 0.26.0
154
168
  - !ruby/object:Gem::Dependency
155
- name: concourse
169
+ name: rubocop
156
170
  requirement: !ruby/object:Gem::Requirement
157
171
  requirements:
158
172
  - - ">="
159
173
  - !ruby/object:Gem::Version
160
- version: 0.15.0
174
+ version: 0.76.0
161
175
  type: :development
162
176
  prerelease: false
163
177
  version_requirements: !ruby/object:Gem::Requirement
164
178
  requirements:
165
179
  - - ">="
166
180
  - !ruby/object:Gem::Version
167
- version: 0.15.0
181
+ version: 0.76.0
168
182
  - !ruby/object:Gem::Dependency
169
183
  name: rdoc
170
184
  requirement: !ruby/object:Gem::Requirement
171
185
  requirements:
172
- - - "~>"
186
+ - - ">="
173
187
  - !ruby/object:Gem::Version
174
188
  version: '4.0'
189
+ - - "<"
190
+ - !ruby/object:Gem::Version
191
+ version: '7'
175
192
  type: :development
176
193
  prerelease: false
177
194
  version_requirements: !ruby/object:Gem::Requirement
178
195
  requirements:
179
- - - "~>"
196
+ - - ">="
180
197
  - !ruby/object:Gem::Version
181
198
  version: '4.0'
199
+ - - "<"
200
+ - !ruby/object:Gem::Version
201
+ version: '7'
182
202
  - !ruby/object:Gem::Dependency
183
203
  name: hoe
184
204
  requirement: !ruby/object:Gem::Requirement
185
205
  requirements:
186
206
  - - "~>"
187
207
  - !ruby/object:Gem::Version
188
- version: '3.16'
208
+ version: '3.20'
189
209
  type: :development
190
210
  prerelease: false
191
211
  version_requirements: !ruby/object:Gem::Requirement
192
212
  requirements:
193
213
  - - "~>"
194
214
  - !ruby/object:Gem::Version
195
- version: '3.16'
215
+ version: '3.20'
196
216
  description: |-
197
- Loofah is a general library for manipulating and transforming HTML/XML
198
- documents and fragments. It's built on top of Nokogiri and libxml2, so
199
- it's fast and has a nice API.
217
+ Loofah is a general library for manipulating and transforming HTML/XML documents and fragments, built on top of Nokogiri.
200
218
 
201
- Loofah excels at HTML sanitization (XSS prevention). It includes some
202
- nice HTML sanitizers, which are based on HTML5lib's whitelist, so it
203
- most likely won't make your codes less secure. (These statements have
204
- not been evaluated by Netexperts.)
219
+ Loofah excels at HTML sanitization (XSS prevention). It includes some nice HTML sanitizers, which are based on HTML5lib's safelist, so it most likely won't make your codes less secure. (These statements have not been evaluated by Netexperts.)
205
220
 
206
- ActiveRecord extensions for sanitization are available in the
207
- [`loofah-activerecord` gem](https://github.com/flavorjones/loofah-activerecord).
221
+ ActiveRecord extensions for sanitization are available in the [`loofah-activerecord` gem](https://github.com/flavorjones/loofah-activerecord).
208
222
  email:
209
223
  - mike.dalessio@gmail.com
210
224
  - bryan@brynary.com
@@ -235,17 +249,19 @@ files:
235
249
  - lib/loofah/html/document.rb
236
250
  - lib/loofah/html/document_fragment.rb
237
251
  - lib/loofah/html5/libxml2_workarounds.rb
252
+ - lib/loofah/html5/safelist.rb
238
253
  - lib/loofah/html5/scrub.rb
239
- - lib/loofah/html5/whitelist.rb
240
254
  - lib/loofah/instance_methods.rb
241
255
  - lib/loofah/metahelpers.rb
242
256
  - lib/loofah/scrubber.rb
243
257
  - lib/loofah/scrubbers.rb
244
258
  - lib/loofah/xml/document.rb
245
259
  - lib/loofah/xml/document_fragment.rb
260
+ - test/assets/msword.html
246
261
  - test/assets/testdata_sanitizer_tests1.dat
247
262
  - test/helper.rb
248
263
  - test/html5/test_sanitizer.rb
264
+ - test/html5/test_scrub.rb
249
265
  - test/integration/test_ad_hoc.rb
250
266
  - test/integration/test_helpers.rb
251
267
  - test/integration/test_html.rb
@@ -259,7 +275,8 @@ files:
259
275
  homepage: https://github.com/flavorjones/loofah
260
276
  licenses:
261
277
  - MIT
262
- metadata: {}
278
+ metadata:
279
+ homepage_uri: https://github.com/flavorjones/loofah
263
280
  post_install_message:
264
281
  rdoc_options:
265
282
  - "--main"
@@ -277,10 +294,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
294
  - !ruby/object:Gem::Version
278
295
  version: '0'
279
296
  requirements: []
280
- rubyforge_project:
281
- rubygems_version: 2.6.12
297
+ rubygems_version: 3.0.3
282
298
  signing_key:
283
299
  specification_version: 4
284
300
  summary: Loofah is a general library for manipulating and transforming HTML/XML documents
285
- and fragments
301
+ and fragments, built on top of Nokogiri
286
302
  test_files: []
@@ -1,186 +0,0 @@
1
- require 'set'
2
-
3
- module Loofah
4
- module HTML5 # :nodoc:
5
- #
6
- # HTML whitelist lifted from HTML5lib sanitizer code:
7
- #
8
- # http://code.google.com/p/html5lib/
9
- #
10
- # <html5_license>
11
- #
12
- # Copyright (c) 2006-2008 The Authors
13
- #
14
- # Contributors:
15
- # James Graham - jg307@cam.ac.uk
16
- # Anne van Kesteren - annevankesteren@gmail.com
17
- # Lachlan Hunt - lachlan.hunt@lachy.id.au
18
- # Matt McDonald - kanashii@kanashii.ca
19
- # Sam Ruby - rubys@intertwingly.net
20
- # Ian Hickson (Google) - ian@hixie.ch
21
- # Thomas Broyer - t.broyer@ltgt.net
22
- # Jacques Distler - distler@golem.ph.utexas.edu
23
- # Henri Sivonen - hsivonen@iki.fi
24
- # The Mozilla Foundation (contributions from Henri Sivonen since 2008)
25
- #
26
- # Permission is hereby granted, free of charge, to any person
27
- # obtaining a copy of this software and associated documentation
28
- # files (the "Software"), to deal in the Software without
29
- # restriction, including without limitation the rights to use, copy,
30
- # modify, merge, publish, distribute, sublicense, and/or sell copies
31
- # of the Software, and to permit persons to whom the Software is
32
- # furnished to do so, subject to the following conditions:
33
- #
34
- # The above copyright notice and this permission notice shall be
35
- # included in all copies or substantial portions of the Software.
36
- #
37
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
38
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
40
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
41
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
42
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
44
- # DEALINGS IN THE SOFTWARE.
45
- #
46
- # </html5_license>
47
- module WhiteList
48
-
49
- ACCEPTABLE_ELEMENTS = Set.new %w[a abbr acronym address area
50
- article aside audio b bdi bdo big blockquote br button canvas
51
- caption center cite code col colgroup command datalist dd del
52
- details dfn dir div dl dt em fieldset figcaption figure footer
53
- font form h1 h2 h3 h4 h5 h6 header hr i img input ins kbd label
54
- legend li main map mark menu meter nav ol output optgroup option p
55
- pre q s samp section select small span strike strong sub summary
56
- sup table tbody td textarea tfoot th thead time tr tt u ul var
57
- video]
58
-
59
- MATHML_ELEMENTS = Set.new %w[annotation annotation-xml maction math merror mfrac
60
- mfenced mi mmultiscripts mn mo mover mpadded mphantom mprescripts mroot mrow
61
- mspace msqrt mstyle msub msubsup msup mtable mtd mtext mtr munder
62
- munderover none semantics]
63
-
64
- SVG_ELEMENTS = Set.new %w[a animate animateColor animateMotion animateTransform
65
- circle clipPath defs desc ellipse feGaussianBlur filter font-face
66
- font-face-name font-face-src foreignObject
67
- g glyph hkern linearGradient line marker mask metadata missing-glyph
68
- mpath path polygon polyline radialGradient rect set stop svg switch symbol
69
- text textPath title tspan use]
70
-
71
- ACCEPTABLE_ATTRIBUTES = Set.new %w[abbr accept accept-charset accesskey action
72
- align alt axis border cellpadding cellspacing char charoff charset
73
- checked cite class clear cols colspan color compact coords datetime
74
- dir disabled enctype for frame headers height href hreflang hspace id
75
- ismap label lang longdesc loop loopcount loopend loopstart
76
- maxlength media method multiple name nohref
77
- noshade nowrap poster preload prompt readonly rel rev rows rowspan rules scope
78
- selected shape size span src start style summary tabindex target title
79
- type usemap valign value vspace width xml:lang]
80
-
81
- MATHML_ATTRIBUTES = Set.new %w[actiontype align close
82
- columnalign columnlines columnspacing columnspan depth display
83
- displaystyle encoding equalcolumns equalrows fence fontstyle fontweight
84
- frame height linethickness lspace mathbackground mathcolor mathvariant
85
- maxsize minsize open other rowalign rowlines
86
- rowspacing rowspan rspace scriptlevel selection separator separators
87
- stretchy width xlink:href xlink:show xlink:type xmlns xmlns:xlink]
88
-
89
- SVG_ATTRIBUTES = Set.new %w[accent-height accumulate additive alphabetic
90
- arabic-form ascent attributeName attributeType baseProfile bbox begin
91
- by calcMode cap-height class clip-path clip-rule color
92
- color-interpolation-filters color-rendering content cx cy d dx
93
- dy descent display dur end fill fill-opacity fill-rule
94
- filterRes filterUnits font-family
95
- font-size font-stretch font-style font-variant font-weight from fx fy g1
96
- g2 glyph-name gradientUnits hanging height horiz-adv-x horiz-origin-x id
97
- ideographic k keyPoints keySplines keyTimes lang marker-end
98
- marker-mid marker-start markerHeight markerUnits markerWidth
99
- maskContentUnits maskUnits mathematical max method min name offset opacity orient origin
100
- overline-position overline-thickness panose-1 path pathLength
101
- patternContentUnits patternTransform patternUnits points
102
- preserveAspectRatio primitiveUnits r refX refY repeatCount repeatDur
103
- requiredExtensions requiredFeatures restart rotate rx ry slope spacing
104
- startOffset stdDeviation stemh
105
- stemv stop-color stop-opacity strikethrough-position
106
- strikethrough-thickness stroke stroke-dasharray stroke-dashoffset
107
- stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity
108
- stroke-width systemLanguage target text-anchor to transform type u1
109
- u2 underline-position underline-thickness unicode unicode-range
110
- units-per-em values version viewBox visibility width widths x
111
- x-height x1 x2 xlink:actuate xlink:arcrole xlink:href xlink:role
112
- xlink:show xlink:title xlink:type xml:base xml:lang xml:space xmlns
113
- xmlns:xlink y y1 y2 zoomAndPan]
114
-
115
- ATTR_VAL_IS_URI = Set.new %w[href src cite action longdesc xlink:href xml:base poster preload]
116
-
117
- SVG_ATTR_VAL_ALLOWS_REF = Set.new %w[clip-path color-profile cursor fill
118
- filter marker marker-start marker-mid marker-end mask stroke]
119
-
120
- SVG_ALLOW_LOCAL_HREF = Set.new %w[altGlyph animate animateColor animateMotion
121
- animateTransform cursor feImage filter linearGradient pattern
122
- radialGradient textpath tref set use]
123
-
124
- ACCEPTABLE_CSS_PROPERTIES = Set.new %w[azimuth background-color
125
- border-bottom-color border-collapse border-color border-left-color
126
- border-right-color border-top-color clear color cursor direction
127
- display elevation float font font-family font-size font-style
128
- font-variant font-weight height letter-spacing line-height list-style-type
129
- overflow pause pause-after pause-before pitch pitch-range richness speak
130
- speak-header speak-numeral speak-punctuation speech-rate stress
131
- text-align text-decoration text-indent unicode-bidi vertical-align
132
- voice-family volume white-space width]
133
-
134
- ACCEPTABLE_CSS_KEYWORDS = Set.new %w[auto aqua black block blue bold both bottom
135
- brown center collapse dashed dotted fuchsia gray green !important
136
- italic left lime maroon medium none navy normal nowrap olive pointer
137
- purple red right solid silver teal top transparent underline white
138
- yellow]
139
-
140
- ACCEPTABLE_CSS_FUNCTIONS = Set.new %w[calc rgb]
141
-
142
- SHORTHAND_CSS_PROPERTIES = Set.new %w[background border margin padding]
143
-
144
- ACCEPTABLE_SVG_PROPERTIES = Set.new %w[fill fill-opacity fill-rule stroke
145
- stroke-width stroke-linecap stroke-linejoin stroke-opacity]
146
-
147
- PROTOCOL_SEPARATOR = /:|(&#0*58)|(&#x70)|(&#x0*3a)|(%|&#37;)3A/i
148
-
149
- ACCEPTABLE_PROTOCOLS = Set.new %w[ed2k ftp http https irc mailto news gopher nntp
150
- telnet webcal xmpp callto feed urn aim rsync tag ssh sftp rtsp afs data]
151
-
152
- ACCEPTABLE_URI_DATA_MEDIATYPES = Set.new %w[text/plain text/css image/png image/gif
153
- image/jpeg image/svg+xml]
154
-
155
- # subclasses may define their own versions of these constants
156
- ALLOWED_ELEMENTS = ACCEPTABLE_ELEMENTS + MATHML_ELEMENTS + SVG_ELEMENTS
157
- ALLOWED_ATTRIBUTES = ACCEPTABLE_ATTRIBUTES + MATHML_ATTRIBUTES + SVG_ATTRIBUTES
158
- ALLOWED_CSS_PROPERTIES = ACCEPTABLE_CSS_PROPERTIES
159
- ALLOWED_CSS_KEYWORDS = ACCEPTABLE_CSS_KEYWORDS
160
- ALLOWED_CSS_FUNCTIONS = ACCEPTABLE_CSS_FUNCTIONS
161
- ALLOWED_SVG_PROPERTIES = ACCEPTABLE_SVG_PROPERTIES
162
- ALLOWED_PROTOCOLS = ACCEPTABLE_PROTOCOLS
163
- ALLOWED_URI_DATA_MEDIATYPES = ACCEPTABLE_URI_DATA_MEDIATYPES
164
-
165
- VOID_ELEMENTS = Set.new %w[
166
- base
167
- link
168
- meta
169
- hr
170
- br
171
- img
172
- embed
173
- param
174
- area
175
- col
176
- input
177
- ]
178
-
179
- # additional tags we should consider safe since we have libxml2 fixing up our documents.
180
- TAGS_SAFE_WITH_LIBXML2 = Set.new %w[html head body]
181
- ALLOWED_ELEMENTS_WITH_LIBXML2 = ALLOWED_ELEMENTS + TAGS_SAFE_WITH_LIBXML2
182
- end
183
-
184
- ::Loofah::MetaHelpers.add_downcased_set_members_to_all_set_constants ::Loofah::HTML5::WhiteList
185
- end
186
- end