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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 55986c6edc7d96bf6301f01ed6c8474a0e0eedc3
4
- data.tar.gz: e1e5ef44e194bd9333cfc92f9d182bedaac5799c
2
+ SHA256:
3
+ metadata.gz: 29f0764dd4fc0eed44139b573bd3708917cab618126b094b9faa42d26a29d949
4
+ data.tar.gz: e1e9cc2ecbd68de48d1f2554a65b86bed0756616008cf9c9a7ed62af1197afa4
5
5
  SHA512:
6
- metadata.gz: 7d45dbc3cb1e275e81f127e92107ba540da3f8294d486e927325cd9a8cb8c742ba1f34c14101b46437242b3778911c3f7392bf822b2dbeccd835410f52ca757f
7
- data.tar.gz: 70318ae204e34718bbdf818c6be1d302e5377eec163ff1380556e219443d1d0c42887f5e6e69b4d2ef8876e6cbbaa4f2f7f84d73fe71e13bbe1b2d10b199e072
6
+ metadata.gz: 05bc54adcab4ee55e52f69685366ba81e492a6b6c25c8e282d79d4ec85349f8ac37c3e34b74ed81089bda662ebed620c208a7a46bc64f4a504ec1bf51f7c8bf9
7
+ data.tar.gz: 8b0e5d75ab88d683240183b5b3e4ed3d1a1fd26bac0d89780ce64722a3d05cba95c42376208e294ad1b3b215fcb90a795e479a2d0e8a3fd643d3b136e88bb562
@@ -1,7 +1,82 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.4.0 / 2019-11-25
4
+
5
+ ### Features
6
+
7
+ * Allow CSS property `max-width` [#175] (Thanks, @bchaney!)
8
+ * Allow CSS sizes expressed in `rem` [#176, #177]
9
+ * Add `frozen_string_literal: true` magic comment to all `lib` files. [#118]
10
+
11
+
12
+ ## 2.3.1 / 2019-10-22
13
+
14
+ ### Security
15
+
16
+ Address CVE-2019-15587: Unsanitized JavaScript may occur in sanitized output when a crafted SVG element is republished.
17
+
18
+ This CVE's public notice is at https://github.com/flavorjones/loofah/issues/171
19
+
20
+
21
+ ## 2.3.0 / 2019-09-28
22
+
23
+ ### Features
24
+
25
+ * Expand set of allowed protocols to include `tel:` and `line:`. [#104, #147]
26
+ * Expand set of allowed CSS functions. [related to #122]
27
+ * Allow greater precision in shorthand CSS values. [#149] (Thanks, @danfstucky!)
28
+ * Allow CSS property `list-style` [#162] (Thanks, @jaredbeck!)
29
+ * Allow CSS keywords `thick` and `thin` [#168] (Thanks, @georgeclaghorn!)
30
+ * Allow HTML property `contenteditable` [#167] (Thanks, @andreynering!)
31
+
32
+
33
+ ### Bug fixes
34
+
35
+ * CSS hex values are no longer limited to lowercase hex. Previously uppercase hex were scrubbed. [#165] (Thanks, @asok!)
36
+
37
+
38
+ ### Deprecations / Name Changes
39
+
40
+ The following method and constants are hereby deprecated, and will be completely removed in a future release:
41
+
42
+ * Deprecate `Loofah::Helpers::ActionView.white_list_sanitizer`, please use `Loofah::Helpers::ActionView.safe_list_sanitizer` instead.
43
+ * Deprecate `Loofah::Helpers::ActionView::WhiteListSanitizer`, please use `Loofah::Helpers::ActionView::SafeListSanitizer` instead.
44
+ * Deprecate `Loofah::HTML5::WhiteList`, please use `Loofah::HTML5::SafeList` instead.
45
+
46
+ Thanks to @JuanitoFatas for submitting these changes in #164 and for making the language used in Loofah more inclusive.
47
+
48
+
49
+ ## 2.2.3 / 2018-10-30
50
+
51
+ ### Security
52
+
53
+ Address CVE-2018-16468: Unsanitized JavaScript may occur in sanitized output when a crafted SVG element is republished.
54
+
55
+ This CVE's public notice is at https://github.com/flavorjones/loofah/issues/154
56
+
57
+
58
+ ## Meta / 2018-10-27
59
+
60
+ The mailing list is now on Google Groups [#146](https://github.com/flavorjones/loofah/issues/146):
61
+
62
+ * Mail: loofah-talk@googlegroups.com
63
+ * Archive: https://groups.google.com/forum/#!forum/loofah-talk
64
+
65
+ This change was made because librelist no longer appears to be maintained.
66
+
67
+
68
+ ## 2.2.2 / 2018-03-22
69
+
70
+ Make public `Loofah::HTML5::Scrub.force_correct_attribute_escaping!`,
71
+ which was previously a private method. This is so that downstream gems
72
+ (like rails-html-sanitizer) can use this logic directly for their own
73
+ attribute scrubbers should they need to address CVE-2018-8048.
74
+
75
+
3
76
  ## 2.2.1 / 2018-03-19
4
77
 
78
+ ### Security
79
+
5
80
  Addresses CVE-2018-8048. Loofah allowed non-whitelisted attributes to be present in sanitized output when input with specially-crafted HTML fragments.
6
81
 
7
82
  This CVE's public notice is at https://github.com/flavorjones/loofah/issues/144
@@ -9,7 +84,7 @@ This CVE's public notice is at https://github.com/flavorjones/loofah/issues/144
9
84
 
10
85
  ## 2.2.0 / 2018-02-11
11
86
 
12
- Features:
87
+ ### Features:
13
88
 
14
89
  * Support HTML5 `<main>` tag. #133 (Thanks, @MothOnMars!)
15
90
  * Recognize HTML5 block elements. #136 (Thanks, @MothOnMars!)
@@ -17,32 +92,32 @@ Features:
17
92
  * Support for whitelisting CSS functions, initially just `calc` and `rgb`. #122/#123/#129 (Thanks, @NikoRoberts!)
18
93
  * Whitelist CSS property `list-style-type`. #68/#137/#142 (Thanks, @andela-ysanni and @NikoRoberts!)
19
94
 
20
- Bugfixes:
95
+ ### Bugfixes:
21
96
 
22
97
  * Properly handle nested `script` tags. #127.
23
98
 
24
99
 
25
100
  ## 2.1.1 / 2017-09-24
26
101
 
27
- Bugfixes:
102
+ ### Bugfixes:
28
103
 
29
104
  * Removed warning for unused variable. #124 (Thanks, @y-yagi!)
30
105
 
31
106
 
32
107
  ## 2.1.0 / 2017-09-24
33
108
 
34
- Notes:
109
+ ### Notes:
35
110
 
36
111
  * Re-implemented CSS parsing and sanitization using the [crass](https://github.com/rgrove/crass) library. #91
37
112
 
38
113
 
39
- Features:
114
+ ### Features:
40
115
 
41
116
  * Added :noopener HTML scrubber (Thanks, @tastycode!)
42
117
  * Support `data` URIs with the following media types: text/plain, text/css, image/png, image/gif, image/jpeg, image/svg+xml. #101, #120. (Thanks, @mrpasquini!)
43
118
 
44
119
 
45
- Bugfixes:
120
+ ### Bugfixes:
46
121
 
47
122
  * The :unprintable scrubber now scrubs unprintable characters in CDATA nodes (like `<script>`). #124
48
123
  * Allow negative values in CSS properties. Restores functionality that was reverted in v2.0.3. #91
@@ -50,14 +125,14 @@ Bugfixes:
50
125
 
51
126
  ## 2.0.3 / 2015-08-17
52
127
 
53
- Bug fixes:
128
+ ### Bug fixes:
54
129
 
55
130
  * Revert support for negative values in CSS properties due to slow performance. #90 (Related to #85.)
56
131
 
57
132
 
58
133
  ## 2.0.2 / 2015-05-05
59
134
 
60
- Bug fixes:
135
+ ### Bug fixes:
61
136
 
62
137
  * Fix error with `#to_text` when Loofah::Helpers hadn't been required. #75
63
138
  * Allow multi-word data attributes. #84 (Thanks, @jstorimer!)
@@ -66,24 +141,24 @@ Bug fixes:
66
141
 
67
142
  ## 2.0.1 / 2014-08-21
68
143
 
69
- Bug fixes:
144
+ ### Bug fixes:
70
145
 
71
146
  * Load RR correctly when running test files directly. (Thanks, @ktdreyer!)
72
147
 
73
148
 
74
- Notes:
149
+ ### Notes:
75
150
 
76
151
  * Extracted HTML5::Scrub#scrub_css_attribute to accommodate the Rails integration work. (Thanks, @kaspth!)
77
152
 
78
153
 
79
154
  ## 2.0.0 / 2014-05-09
80
155
 
81
- Compatibility notes:
156
+ ### Compatibility notes:
82
157
 
83
158
  * ActionView helpers now must be required explicitly: `require "loofah/helpers"`
84
159
  * Support for Ruby 1.8.7 and prior has been dropped
85
160
 
86
- Enhancements:
161
+ ### Enhancements:
87
162
 
88
163
  * HTML5 whitelist allows the following ...
89
164
  * tags: `article`, `aside`, `bdi`, `bdo`, `canvas`, `command`, `datalist`, `details`, `figcaption`, `figure`, `footer`, `header`, `mark`, `meter`, `nav`, `output`, `section`, `summary`, `time`
@@ -93,7 +168,7 @@ Enhancements:
93
168
  * `Loofah.fragment` accepts an optional encoding argument, compatible with `Nokogiri::HTML::DocumentFragment.parse`. #62 (Thanks, Ben Atkins!)
94
169
  * HTML5 sanitizers now remove attributes without values. (Thanks, Kasper Timm Hansen!)
95
170
 
96
- Bug fixes:
171
+ ### Bug fixes:
97
172
 
98
173
  * HTML5 sanitizers' CSS keyword check now actually works (broken in v2.0). Additional regression tests added. (Thanks, Kasper Timm Hansen!)
99
174
  * HTML5 sanitizers now allow negative arguments to CSS. #64 (Thanks, Jon Calhoun!)
@@ -106,7 +181,7 @@ Bug fixes:
106
181
 
107
182
  ## 1.2.0 (2011-08-08)
108
183
 
109
- Enhancements:
184
+ ### Enhancements:
110
185
 
111
186
  * Loofah::Helpers.sanitize_css is a replacement for Rails's built-in sanitize_css helper.
112
187
  * Improving ActionView integration.
@@ -114,7 +189,7 @@ Enhancements:
114
189
 
115
190
  ## 1.1.0 (2011-08-08)
116
191
 
117
- Enhancements:
192
+ ### Enhancements:
118
193
 
119
194
  * Additional HTML5lib whitelist elements (from html5lib 1524:80b5efe26230).
120
195
  Up to date with HTML5lib ruby code as of 1723:7ee6a0331856.
@@ -124,7 +199,7 @@ Enhancements:
124
199
 
125
200
  ## 1.0.0 (2010-10-26)
126
201
 
127
- Notes:
202
+ ### Notes:
128
203
 
129
204
  * Moved ActiveRecord functionality into `loofah-activerecord` gem.
130
205
  * Removed DEPRECATIONS.rdoc documenting 0.3.0 API changes.
@@ -132,7 +207,7 @@ Notes:
132
207
 
133
208
  ## 0.4.7 (2010-03-09)
134
209
 
135
- Enhancements:
210
+ ### Enhancements:
136
211
 
137
212
  * New methods Loofah::HTML::Document#to_text and
138
213
  Loofah::HTML::DocumentFragment#to_text do the right thing with
@@ -145,23 +220,23 @@ Enhancements:
145
220
 
146
221
  ## 0.4.4, 0.4.5, 0.4.6 (2010-02-01)
147
222
 
148
- Enhancements:
223
+ ### Enhancements:
149
224
 
150
225
  * Loofah::HTML::Document#text and Loofah::HTML::DocumentFragment#text now escape HTML entities.
151
226
 
152
- Bug fixes:
227
+ ### Bug fixes:
153
228
 
154
229
  * Loofah::XssFoliate was not properly escaping HTML entities when implicitly scrubbing a string attribute. GH #17
155
230
 
156
231
 
157
232
  ## 0.4.3 (2010-01-29)
158
233
 
159
- Enhancements:
234
+ ### Enhancements:
160
235
 
161
236
  * All built-in scrubbers are accepted by ActiveRecord::Base.xss_foliate
162
237
  * Loofah::XssFoliate.xss_foliate_all_models replaces use of the constant LOOFAH_XSS_FOLIATE_ALL_MODELS
163
238
 
164
- Miscellaneous:
239
+ ### Miscellaneous:
165
240
 
166
241
  * Modified documentation for bootstrapping XssFoliate in a Rails app,
167
242
  since the use of Bundler breaks the previously-documented method. To
@@ -170,18 +245,18 @@ Miscellaneous:
170
245
 
171
246
  ## 0.4.2 (2010-01-22)
172
247
 
173
- Enhancements:
248
+ ### Enhancements:
174
249
 
175
250
  * Implemented Node#scrub! for scrubbing subtrees.
176
251
  * Implemented NodeSet#scrub! for scrubbing a set of subtrees.
177
252
  * Document.text now only serializes <body> contents (ignores <head>)
178
253
  * <head>, <html> and <body> added to the HTML5lib whitelist.
179
254
 
180
- Bug fixes:
255
+ ### Bug fixes:
181
256
 
182
257
  * Supporting Rails apps that aren't loading ActiveRecord. GH #10
183
258
 
184
- Miscellaneous:
259
+ ### Miscellaneous:
185
260
 
186
261
  * Mailing list is now loofah@librelist.com / http://librelist.com
187
262
  * IRC channel is now \#loofah on freenode.
@@ -189,14 +264,14 @@ Miscellaneous:
189
264
 
190
265
  ## 0.4.1 (2009-11-23)
191
266
 
192
- Bugfix:
267
+ ### Bugfix:
193
268
 
194
269
  * Manifest fixed. Whoops.
195
270
 
196
271
 
197
272
  ## 0.4.0 (2009-11-21)
198
273
 
199
- Enhancements:
274
+ ### Enhancements:
200
275
 
201
276
  * Scrubber class introduced, allowing development of custom scrubbers.
202
277
  * Added support for XML documents and fragments.
@@ -207,20 +282,20 @@ Enhancements:
207
282
 
208
283
  ## 0.3.1 (2009-10-12)
209
284
 
210
- Bug fixes:
285
+ ### Bug fixes:
211
286
 
212
287
  * Scrubbed Documents properly render html, head and body tags when serialized.
213
288
 
214
289
 
215
290
  ## 0.3.0 (2009-10-06)
216
291
 
217
- Enhancements:
292
+ ### Enhancements:
218
293
 
219
294
  * New ActiveRecord extension `xss_foliate`, a drop-in replacement for xss_terminate[http://github.com/look/xss_terminate/tree/master].
220
295
  * Replacement methods for Rails's helpers, Loofah::Rails.sanitize and Loofah::Rails.strip_tags.
221
296
  * Official support (and test coverage) for Rails versions 2.3, 2.2, 2.1, 2.0 and 1.2.
222
297
 
223
- Deprecations:
298
+ ### Deprecations:
224
299
 
225
300
  * The methods strip_tags, whitewash, whitewash_document, sanitize, and
226
301
  sanitize_document have been deprecated. See DEPRECATED.rdoc for
@@ -229,7 +304,7 @@ Deprecations:
229
304
 
230
305
  ## 0.2.2 (2009-09-30)
231
306
 
232
- Enhancements:
307
+ ### Enhancements:
233
308
 
234
309
  * ActiveRecord extension scrubs fields in a before_validation callback
235
310
  (was previously in a before_save)
@@ -237,12 +312,12 @@ Enhancements:
237
312
 
238
313
  ## 0.2.1 (2009-09-19)
239
314
 
240
- Enhancements:
315
+ ### Enhancements:
241
316
 
242
317
  * when loaded in a Rails app, automatically extend ActiveRecord::Base
243
318
  with html_fragment and html_document. GH #6 (Thanks Josh Nichols!)
244
319
 
245
- Bugfixes:
320
+ ### Bugfixes:
246
321
 
247
322
  * ActiveRecord scrubbing should generate strings instead of Document or
248
323
  DocumentFragment objects. GH #5
data/Gemfile CHANGED
@@ -7,16 +7,17 @@ source "https://rubygems.org/"
7
7
  gem "nokogiri", ">=1.5.9"
8
8
  gem "crass", "~>1.0.2"
9
9
 
10
- gem "rake", ">=0.8", :group => [:development, :test]
10
+ gem "rake", "~>12.3", :group => [:development, :test]
11
11
  gem "minitest", "~>2.2", :group => [:development, :test]
12
12
  gem "rr", "~>1.2.0", :group => [:development, :test]
13
- gem "json", ">=0", :group => [:development, :test]
14
- gem "hoe-gemspec", ">=0", :group => [:development, :test]
15
- gem "hoe-debugging", ">=0", :group => [:development, :test]
16
- gem "hoe-bundler", ">=0", :group => [:development, :test]
17
- gem "hoe-git", ">=0", :group => [:development, :test]
18
- gem "concourse", ">=0.15.0", :group => [:development, :test]
19
- gem "rdoc", "~>4.0", :group => [:development, :test]
20
- gem "hoe", "~>3.16", :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]
21
22
 
22
23
  # vim: syntax=ruby
@@ -16,17 +16,19 @@ lib/loofah/helpers.rb
16
16
  lib/loofah/html/document.rb
17
17
  lib/loofah/html/document_fragment.rb
18
18
  lib/loofah/html5/libxml2_workarounds.rb
19
+ lib/loofah/html5/safelist.rb
19
20
  lib/loofah/html5/scrub.rb
20
- lib/loofah/html5/whitelist.rb
21
21
  lib/loofah/instance_methods.rb
22
22
  lib/loofah/metahelpers.rb
23
23
  lib/loofah/scrubber.rb
24
24
  lib/loofah/scrubbers.rb
25
25
  lib/loofah/xml/document.rb
26
26
  lib/loofah/xml/document_fragment.rb
27
+ test/assets/msword.html
27
28
  test/assets/testdata_sanitizer_tests1.dat
28
29
  test/helper.rb
29
30
  test/html5/test_sanitizer.rb
31
+ test/html5/test_scrub.rb
30
32
  test/integration/test_ad_hoc.rb
31
33
  test/integration/test_helpers.rb
32
34
  test/integration/test_html.rb
data/README.md CHANGED
@@ -1,36 +1,29 @@
1
1
  # Loofah
2
2
 
3
3
  * https://github.com/flavorjones/loofah
4
- * http://rubydoc.info/github/flavorjones/loofah/master/frames
5
- * http://librelist.com/browser/loofah
4
+ * Docs: http://rubydoc.info/github/flavorjones/loofah/master/frames
5
+ * Mailing list: [loofah-talk@googlegroups.com](https://groups.google.com/forum/#!forum/loofah-talk)
6
6
 
7
7
  ## Status
8
8
 
9
9
  |System|Status|
10
10
  |--|--|
11
- | Concourse | [![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/loofah/jobs/ruby-2.5/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/loofah?groups=master) |
11
+ | Concourse CI | [![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/loofah/jobs/ruby-2.5/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/loofah?groups=master) |
12
12
  | Code Climate | [![Code Climate](https://codeclimate.com/github/flavorjones/loofah.svg)](https://codeclimate.com/github/flavorjones/loofah) |
13
- | Version Eye | [![Version Eye](https://www.versioneye.com/ruby/loofah/badge.png)](https://www.versioneye.com/ruby/loofah) |
14
13
 
15
14
 
16
15
  ## Description
17
16
 
18
- Loofah is a general library for manipulating and transforming HTML/XML
19
- documents and fragments. It's built on top of Nokogiri and libxml2, so
20
- it's fast and has a nice API.
17
+ Loofah is a general library for manipulating and transforming HTML/XML documents and fragments, built on top of Nokogiri.
21
18
 
22
- Loofah excels at HTML sanitization (XSS prevention). It includes some
23
- nice HTML sanitizers, which are based on HTML5lib's whitelist, so it
24
- most likely won't make your codes less secure. (These statements have
25
- not been evaluated by Netexperts.)
19
+ 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.)
26
20
 
27
- ActiveRecord extensions for sanitization are available in the
28
- [`loofah-activerecord` gem](https://github.com/flavorjones/loofah-activerecord).
21
+ ActiveRecord extensions for sanitization are available in the [`loofah-activerecord` gem](https://github.com/flavorjones/loofah-activerecord).
29
22
 
30
23
 
31
24
  ## Features
32
25
 
33
- * Easily write custom scrubbers for HTML/XML leveraging the sweetness of Nokogiri (and HTML5lib's whitelists).
26
+ * Easily write custom scrubbers for HTML/XML leveraging the sweetness of Nokogiri (and HTML5lib's safelists).
34
27
  * Common HTML sanitizing tasks are built-in:
35
28
  * _Strip_ unsafe tags, leaving behind only the inner text.
36
29
  * _Prune_ unsafe tags and their subtrees, removing all traces that they ever existed.
@@ -222,7 +215,7 @@ Loofah.xml_document(File.read('plague.xml')).scrub!(bring_out_your_dead)
222
215
  === Built-In HTML Scrubbers
223
216
 
224
217
  Loofah comes with a set of sanitizing scrubbers that use HTML5lib's
225
- whitelist algorithm:
218
+ safelist algorithm:
226
219
 
227
220
  ``` ruby
228
221
  doc.scrub!(:strip) # replaces unknown/unsafe tags with their inner text
@@ -301,9 +294,10 @@ The bug tracker is available here:
301
294
 
302
295
  * https://github.com/flavorjones/loofah/issues
303
296
 
304
- And the mailing list is on librelist:
297
+ And the mailing list is on Google Groups:
305
298
 
306
- * loofah@librelist.com / http://librelist.com
299
+ * Mail: loofah-talk@googlegroups.com
300
+ * Archive: https://groups.google.com/forum/#!forum/loofah-talk
307
301
 
308
302
  And the IRC channel is \#loofah on freenode.
309
303