loofah 2.19.0 → 2.23.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
2
  SHA256:
3
- metadata.gz: 3d59ed56910860de60170e919b3ab77b382f00eadc5d37518a7a395edabc8a4f
4
- data.tar.gz: d0ed6a2362ec8b366f4739a67c2197a24c45e0681cba6e5bd6b7b55617d492dc
3
+ metadata.gz: 9817bf69ee1ad2d7e93edad53209db1347c9ec360076520532cdf60ad158a8f6
4
+ data.tar.gz: 3381ac563f4b70c4ccca49301ba369f22716da405dd7641af535209e6817258b
5
5
  SHA512:
6
- metadata.gz: dabaf4204cf846132d0b2962cef11534e3043ae8b2be39cbf23dea2fabc3722d83fba8805a5453fca6f2ec80f13c48c62726751f6acf06d3fdfd427297f07968
7
- data.tar.gz: 84d3442b65227346d62df8ea24ef0febe3212b1a1bdb61266f22cafc356467637f2a3a050d4c52672d55e081a3e040d2cb423961d571cf364978265398742f47
6
+ metadata.gz: 482eeac3b61aba7e1b517aaab8a6d010ae44bd5b99b749cdabb5381936b4b9e8f97c62d99a60bdf1fbf64c2dba8c33062b676083f4e82d7e07f33e7666fe148f
7
+ data.tar.gz: 69234fb9c4d7d55eb63a18008d035df1117bb6ea10f0f15b57bacc5152103fc0830a53a8d98a63e817360332975e257dbeda223ed43e42813724ce30a3b8d7e6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,105 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.23.1 / 2024-10-25
4
+
5
+ ### Added
6
+
7
+ * Allow CSS properties `min-height` and `max-height`. [#288] @lazyatom
8
+
9
+
10
+ ## 2.23.0 / 2024-10-24
11
+
12
+ ### Added
13
+
14
+ * Allow CSS property `min-width`. [#287] @lazyatom
15
+
16
+
17
+ ## 2.22.0 / 2023-11-13
18
+
19
+ ### Added
20
+
21
+ * A `:targetblank` HTML scrubber which ensures all hyperlinks have `target="_blank"`. [#275] @stefannibrasil and @thdaraujo
22
+ * A `:noreferrer` HTML scrubber which ensures all hyperlinks have `rel=noreferrer`, similar to the `:nofollow` and `:noopener` scrubbers. [#277] @wynksaiddestroy
23
+
24
+
25
+ ## 2.21.4 / 2023-10-10
26
+
27
+ ### Fixed
28
+
29
+ * `Loofah::HTML5::Scrub.scrub_css` is more consistent in preserving whitespace (and lack of whitespace) in CSS property values. In particular, `.scrub_css` no longer inserts whitespace between tokens that did not already have whitespace between them. [[#273](https://github.com/flavorjones/loofah/issues/273), fixes [#271](https://github.com/flavorjones/loofah/issues/271)]
30
+
31
+
32
+ ## 2.21.3 / 2023-05-15
33
+
34
+ ### Fixed
35
+
36
+ * Quash "instance variable not initialized" warning in Ruby < 3.0. [[#268](https://github.com/flavorjones/loofah/issues/268)] (Thanks, [@dharamgollapudi](https://github.com/dharamgollapudi)!)
37
+
38
+
39
+ ## 2.21.2 / 2023-05-11
40
+
41
+ ### Dependencies
42
+
43
+ * Update the dependency on Nokogiri to be `>= 1.12.0`. The dependency in 2.21.0 and 2.21.1 was left at `>= 1.5.9` but versions before 1.12 would result in a `NameError` exception. [[#266](https://github.com/flavorjones/loofah/issues/266)]
44
+
45
+
46
+ ## 2.21.1 / 2023-05-10
47
+
48
+ ### Fixed
49
+
50
+ * Don't define `HTML5::Document` and `HTML5::DocumentFragment` when Nokogiri is `< 1.14`. In 2.21.0 these classes were defined whenever `Nokogiri::HTML5` was defined, but Nokogiri v1.12 and v1.13 do not support Loofah subclassing properly.
51
+
52
+
53
+ ## 2.21.0 / 2023-05-10
54
+
55
+ ### HTML5 Support
56
+
57
+ Classes `Loofah::HTML5::Document` and `Loofah::HTML5::DocumentFragment` are introduced, along with helper methods:
58
+
59
+ - `Loofah.html5_document`
60
+ - `Loofah.html5_fragment`
61
+ - `Loofah.scrub_html5_document`
62
+ - `Loofah.scrub_html5_fragment`
63
+
64
+ These classes and methods use Nokogiri's HTML5 parser to ensure modern web standards are used.
65
+
66
+ ⚠ HTML5 functionality is only available with Nokogiri v1.14.0 and higher.
67
+
68
+ ⚠ HTML5 functionality is not available for JRuby. Please see [this upstream Nokogiri issue](https://github.com/sparklemotion/nokogiri/issues/2227) if you're interested in helping implement and support HTML5 support.
69
+
70
+
71
+ ### `Loofah::HTML4` module and namespace
72
+
73
+ `Loofah::HTML` has been renamed to `Loofah::HTML4`, and `Loofah::HTML` is aliased to preserve backwards-compatibility. `Nokogiri::HTML` and `Nokogiri::HTML4` parse methods still use libxml2's (or NekoHTML's) HTML4 parser.
74
+
75
+ Take special note that if you rely on the class name of an object in your code, objects will now report a class of `Loofah::HTML4::Foo` where they previously reported `Loofah::HTML::Foo`. Instead of relying on the string returned by `Object#class`, prefer `Class#===` or `Object#is_a?` or `Object#instance_of?`.
76
+
77
+ Future releases of Nokogiri may deprecate `HTML` classes and methods or otherwise change this behavior, so please start using `HTML4` in place of `HTML`.
78
+
79
+
80
+ ### Official support for JRuby
81
+
82
+ This version introduces official support for JRuby. Previously, the test suite had never been green due to differences in behavior in the underlying HTML parser used by Nokogiri. We've updated the test suite to accommodate those differences, and have added JRuby to the CI suite.
83
+
84
+
85
+ ## 2.20.0 / 2023-04-01
86
+
87
+ ### Features
88
+
89
+ * Allow SVG attributes `color-profile`, `cursor`, `filter`, `marker`, and `mask`. [[#246](https://github.com/flavorjones/loofah/issues/246)]
90
+ * Allow SVG elements `altGlyph`, `cursor`, `feImage`, `pattern`, and `tref`. [[#246](https://github.com/flavorjones/loofah/issues/246)]
91
+ * Allow protocols `fax` and `modem`. [[#255](https://github.com/flavorjones/loofah/issues/255)] (Thanks, [@cjba7](https://github.com/cjba7)!)
92
+
93
+
94
+ ## 2.19.1 / 2022-12-13
95
+
96
+ ### Security
97
+
98
+ * Address CVE-2022-23514, inefficient regular expression complexity. See [GHSA-486f-hjj9-9vhh](https://github.com/flavorjones/loofah/security/advisories/GHSA-486f-hjj9-9vhh) for more information.
99
+ * Address CVE-2022-23515, improper neutralization of data URIs. See [GHSA-228g-948r-83gx](https://github.com/flavorjones/loofah/security/advisories/GHSA-228g-948r-83gx) for more information.
100
+ * Address CVE-2022-23516, uncontrolled recursion. See [GHSA-3x8r-x6xp-q4vm](https://github.com/flavorjones/loofah/security/advisories/GHSA-3x8r-x6xp-q4vm) for more information.
101
+
102
+
3
103
  ## 2.19.0 / 2022-09-14
4
104
 
5
105
  ### Features
data/README.md CHANGED
@@ -14,59 +14,62 @@
14
14
 
15
15
  Loofah is a general library for manipulating and transforming HTML/XML documents and fragments, built on top of Nokogiri.
16
16
 
17
- 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.)
17
+ Loofah also includes some HTML sanitizers based on `html5lib`'s safelist, which are a specific application of the general transformation functionality.
18
18
 
19
- ActiveRecord extensions for sanitization are available in the [`loofah-activerecord` gem](https://github.com/flavorjones/loofah-activerecord).
19
+ Active Record extensions for HTML sanitization are available in the [`loofah-activerecord` gem](https://github.com/flavorjones/loofah-activerecord).
20
20
 
21
21
 
22
22
  ## Features
23
23
 
24
- * Easily write custom scrubbers for HTML/XML leveraging the sweetness of Nokogiri (and HTML5lib's safelists).
25
- * Common HTML sanitizing tasks are built-in:
24
+ * Easily write custom transformations for HTML and XML
25
+ * Common HTML sanitizing transformations are built-in:
26
26
  * _Strip_ unsafe tags, leaving behind only the inner text.
27
27
  * _Prune_ unsafe tags and their subtrees, removing all traces that they ever existed.
28
28
  * _Escape_ unsafe tags and their subtrees, leaving behind lots of <tt>&lt;</tt> and <tt>&gt;</tt> entities.
29
29
  * _Whitewash_ the markup, removing all attributes and namespaced nodes.
30
- * Common HTML transformation tasks are built-in:
30
+ * Other common HTML transformations are built-in:
31
31
  * Add the _nofollow_ attribute to all hyperlinks.
32
- * Format markup as plain text, with or without sensible whitespace handling around block elements.
32
+ * Add the _target=\_blank_ attribute to all hyperlinks.
33
+ * Remove _unprintable_ characters from text nodes.
34
+ * Format markup as plain text, with (or without) sensible whitespace handling around block elements.
33
35
  * Replace Rails's `strip_tags` and `sanitize` view helper methods.
34
36
 
35
37
 
36
38
  ## Compare and Contrast
37
39
 
38
- Loofah is one of two known Ruby XSS/sanitization solutions that
39
- guarantees well-formed and valid markup (the other is Sanitize, which
40
- also uses Nokogiri).
40
+ Loofah is both:
41
41
 
42
- Loofah works on XML, XHTML and HTML documents.
42
+ - a general framework for transforming XML, XHTML, and HTML documents
43
+ - a specific toolkit for HTML sanitization
43
44
 
44
- Also, it's pretty fast. Here is a benchmark comparing Loofah to other
45
- commonly-used libraries (ActionView, Sanitize, HTML5lib and HTMLfilter):
45
+ ### General document transformation
46
46
 
47
- * https://gist.github.com/170193
47
+ Loofah tries to make it easy to write your own custom scrubbers for whatever document transformation you need. You don't like the built-in scrubbers? Build your own, like a boss.
48
48
 
49
- Lastly, Loofah is extensible. It's super-easy to write your own custom
50
- scrubbers for whatever document manipulation you need. You don't like
51
- the built-in scrubbers? Build your own, like a boss.
49
+
50
+ ### HTML sanitization
51
+
52
+ Another Ruby library that provides HTML sanitization is [`rgrove/sanitize`](https://github.com/rgrove/sanitize), another library built on top of Nokogiri, which provides a bit more flexibility on the tags and attributes being scrubbed.
53
+
54
+ You may also want to look at [`rails/rails-html-sanitizer`](https://github.com/rails/rails-html-sanitizer) which is built on top of Loofah and provides some useful extensions and additional flexibility in the HTML sanitization.
52
55
 
53
56
 
54
57
  ## The Basics
55
58
 
56
- Loofah wraps [Nokogiri](http://nokogiri.org) in a loving
57
- embrace. Nokogiri is an excellent HTML/XML parser. If you don't know
58
- how Nokogiri works, you might want to pause for a moment and go check
59
- it out. I'll wait.
59
+ Loofah wraps [Nokogiri](http://nokogiri.org) in a loving embrace. Nokogiri is a stable, well-maintained parser for XML, HTML4, and HTML5.
60
60
 
61
- Loofah presents the following classes:
61
+ Loofah implements the following classes:
62
62
 
63
- * `Loofah::HTML::Document` and `Loofah::HTML::DocumentFragment`
64
- * `Loofah::XML::Document` and `Loofah::XML::DocumentFragment`
65
- * `Loofah::Scrubber`
63
+ * `Loofah::HTML5::Document`
64
+ * `Loofah::HTML5::DocumentFragment`
65
+ * `Loofah::HTML4::Document` (aliased as `Loofah::HTML::Document` for now)
66
+ * `Loofah::HTML4::DocumentFragment` (aliased as `Loofah::HTML::DocumentFragment` for now)
67
+ * `Loofah::XML::Document`
68
+ * `Loofah::XML::DocumentFragment`
66
69
 
67
- The documents and fragments are subclasses of the similar Nokogiri classes.
70
+ These document and fragment classes are subclasses of the similarly-named Nokogiri classes `Nokogiri::HTML5::Document` et al.
68
71
 
69
- The Scrubber represents the document manipulation, either by wrapping
72
+ Loofah also implements `Loofah::Scrubber`, which represents the document transformation, either by wrapping
70
73
  a block,
71
74
 
72
75
  ``` ruby
@@ -80,50 +83,49 @@ or by implementing a method.
80
83
 
81
84
  ### Side Note: Fragments vs Documents
82
85
 
83
- Generally speaking, unless you expect to have a DOCTYPE and a single
84
- root node, you don't have a *document*, you have a *fragment*. For
85
- HTML, another rule of thumb is that *documents* have `html` and `body`
86
- tags, and *fragments* usually do not.
86
+ Generally speaking, unless you expect to have a DOCTYPE and a single root node, you don't have a *document*, you have a *fragment*. For HTML, another rule of thumb is that *documents* have `html` and `body` tags, and *fragments* usually do not.
87
+
88
+ **HTML fragments** should be parsed with `Loofah.html5_fragment` or `Loofah.html4_fragment`. The result won't be wrapped in `html` or `body` tags, won't have a DOCTYPE declaration, `head` elements will be silently ignored, and multiple root nodes are allowed.
89
+
90
+ **HTML documents** should be parsed with `Loofah.html5_document` or `Loofah.html4_document`. The result will have a DOCTYPE declaration, along with `html`, `head` and `body` tags.
91
+
92
+ **XML fragments** should be parsed with `Loofah.xml_fragment`. The result won't have a DOCTYPE declaration, and multiple root nodes are allowed.
93
+
94
+ **XML documents** should be parsed with `Loofah.xml_document`. The result will have a DOCTYPE declaration and a single root node.
87
95
 
88
- HTML fragments should be parsed with Loofah.fragment. The result won't
89
- be wrapped in `html` or `body` tags, won't have a DOCTYPE declaration,
90
- `head` elements will be silently ignored, and multiple root nodes are
91
- allowed.
92
96
 
93
- XML fragments should be parsed with Loofah.xml_fragment. The result
94
- won't have a DOCTYPE declaration, and multiple root nodes are allowed.
97
+ ### Side Note: HTML4 vs HTML5
95
98
 
96
- HTML documents should be parsed with Loofah.document. The result will
97
- have a DOCTYPE declaration, along with `html`, `head` and `body` tags.
99
+ _HTML5 functionality is not available on JRuby, or with versions of Nokogiri `< 1.14.0`._
98
100
 
99
- XML documents should be parsed with Loofah.xml_document. The result
100
- will have a DOCTYPE declaration and a single root node.
101
+ Currently, Loofah's methods `Loofah.document` and `Loofah.fragment` are aliases to `.html4_document` and `.html4_fragment`, which use Nokogiri's HTML4 parser. (Similarly, `Loofah::HTML::Document` and `Loofah::HTML::DocumentFragment` are aliased to `Loofah::HTML4::Document` and `Loofah::HTML4::DocumentFragment`.)
101
102
 
103
+ **Please note** that in a future version of Loofah, these methods and classes may switch to using Nokogiri's HTML5 parser and classes on platforms that support it [1].
102
104
 
103
- ### Loofah::HTML::Document and Loofah::HTML::DocumentFragment
105
+ **We strongly recommend that you explicitly use `.html5_document` or `.html5_fragment`** unless you know of a compelling reason not to. If you are sure that you need to use the HTML4 parser, you should explicitly call `.html4_document` or `.html4_fragment` to avoid breakage in a future version.
104
106
 
105
- These classes are subclasses of Nokogiri::HTML::Document and
106
- Nokogiri::HTML::DocumentFragment, so you get all the markup
107
- fixer-uppery and API goodness of Nokogiri.
107
+ [1]: [[feature request] HTML5 parser for JRuby implementation · Issue #2227 · sparklemotion/nokogiri](https://github.com/sparklemotion/nokogiri/issues/2227)
108
108
 
109
- The module methods Loofah.document and Loofah.fragment will parse an
110
- HTML document and an HTML fragment, respectively.
109
+
110
+ ### `Loofah::HTML5::Document` and `Loofah::HTML5::DocumentFragment`
111
+
112
+ These classes are subclasses of `Nokogiri::HTML5::Document` and `Nokogiri::HTML5::DocumentFragment`.
113
+
114
+ The module methods `Loofah.html5_document` and `Loofah.html5_fragment` will parse either an HTML document and an HTML fragment, respectively.
111
115
 
112
116
  ``` ruby
113
- Loofah.document(unsafe_html).is_a?(Nokogiri::HTML::Document) # => true
114
- Loofah.fragment(unsafe_html).is_a?(Nokogiri::HTML::DocumentFragment) # => true
117
+ Loofah.html5_document(unsafe_html).is_a?(Nokogiri::HTML5::Document) # => true
118
+ Loofah.html5_fragment(unsafe_html).is_a?(Nokogiri::HTML5::DocumentFragment) # => true
115
119
  ```
116
120
 
117
- Loofah injects a `scrub!` method, which takes either a symbol (for
118
- built-in scrubbers) or a Loofah::Scrubber object (for custom
119
- scrubbers), and modifies the document in-place.
121
+ Loofah injects a `scrub!` method, which takes either a symbol (for built-in scrubbers) or a `Loofah::Scrubber` object (for custom scrubbers), and modifies the document in-place.
120
122
 
121
123
  Loofah overrides `to_s` to return HTML:
122
124
 
123
125
  ``` ruby
124
126
  unsafe_html = "ohai! <div>div is safe</div> <script>but script is not</script>"
125
127
 
126
- doc = Loofah.fragment(unsafe_html).scrub!(:prune)
128
+ doc = Loofah.html5_fragment(unsafe_html).scrub!(:prune)
127
129
  doc.to_s # => "ohai! <div>div is safe</div> "
128
130
  ```
129
131
 
@@ -136,32 +138,38 @@ doc.text # => "ohai! div is safe "
136
138
  Also, `to_text` is available, which does the right thing with whitespace around block-level and line break elements.
137
139
 
138
140
  ``` ruby
139
- doc = Loofah.fragment("<h1>Title</h1><div>Content<br>Next line</div>")
141
+ doc = Loofah.html5_fragment("<h1>Title</h1><div>Content<br>Next line</div>")
140
142
  doc.text # => "TitleContentNext line" # probably not what you want
141
143
  doc.to_text # => "\nTitle\n\nContent\nNext line\n" # better
142
144
  ```
143
145
 
144
- ### Loofah::XML::Document and Loofah::XML::DocumentFragment
146
+ ### `Loofah::HTML4::Document` and `Loofah::HTML4::DocumentFragment`
147
+
148
+ These classes are subclasses of `Nokogiri::HTML4::Document` and `Nokogiri::HTML4::DocumentFragment`.
149
+
150
+ The module methods `Loofah.html4_document` and `Loofah.html4_fragment` will parse either an HTML document and an HTML fragment, respectively.
151
+
152
+ ``` ruby
153
+ Loofah.html4_document(unsafe_html).is_a?(Nokogiri::HTML4::Document) # => true
154
+ Loofah.html4_fragment(unsafe_html).is_a?(Nokogiri::HTML4::DocumentFragment) # => true
155
+ ```
156
+
157
+ ### `Loofah::XML::Document` and `Loofah::XML::DocumentFragment`
145
158
 
146
- These classes are subclasses of Nokogiri::XML::Document and
147
- Nokogiri::XML::DocumentFragment, so you get all the markup
148
- fixer-uppery and API goodness of Nokogiri.
159
+ These classes are subclasses of `Nokogiri::XML::Document` and `Nokogiri::XML::DocumentFragment`.
149
160
 
150
- The module methods Loofah.xml_document and Loofah.xml_fragment will
151
- parse an XML document and an XML fragment, respectively.
161
+ The module methods `Loofah.xml_document` and `Loofah.xml_fragment` will parse an XML document and an XML fragment, respectively.
152
162
 
153
163
  ``` ruby
154
164
  Loofah.xml_document(bad_xml).is_a?(Nokogiri::XML::Document) # => true
155
165
  Loofah.xml_fragment(bad_xml).is_a?(Nokogiri::XML::DocumentFragment) # => true
156
166
  ```
157
167
 
158
- ### Nodes and NodeSets
168
+ ### Nodes and Node Sets
159
169
 
160
- Nokogiri::XML::Node and Nokogiri::XML::NodeSet also get a `scrub!`
161
- method, which makes it easy to scrub subtrees.
170
+ Nokogiri's `Node` and `NodeSet` classes also get a `scrub!` method, which makes it easy to scrub subtrees.
162
171
 
163
- The following code will apply the `employee_scrubber` only to the
164
- `employee` nodes (and their subtrees) in the document:
172
+ The following code will apply the `employee_scrubber` only to the `employee` nodes (and their subtrees) in the document:
165
173
 
166
174
  ``` ruby
167
175
  Loofah.xml_document(bad_xml).xpath("//employee").scrub!(employee_scrubber)
@@ -173,7 +181,7 @@ And this code will only scrub the first `employee` node and its subtree:
173
181
  Loofah.xml_document(bad_xml).at_xpath("//employee").scrub!(employee_scrubber)
174
182
  ```
175
183
 
176
- ### Loofah::Scrubber
184
+ ### `Loofah::Scrubber`
177
185
 
178
186
  A Scrubber wraps up a block (or method) that is run on a document node:
179
187
 
@@ -187,14 +195,11 @@ end
187
195
  This can then be run on a document:
188
196
 
189
197
  ``` ruby
190
- Loofah.fragment("<span>foo</span><p>bar</p>").scrub!(span2div).to_s
198
+ Loofah.html5_fragment("<span>foo</span><p>bar</p>").scrub!(span2div).to_s
191
199
  # => "<div>foo</div><p>bar</p>"
192
200
  ```
193
201
 
194
- Scrubbers can be run on a document in either a top-down traversal (the
195
- default) or bottom-up. Top-down scrubbers can optionally return
196
- Scrubber::STOP to terminate the traversal of a subtree. Read below and
197
- in the Loofah::Scrubber class for more detailed usage.
202
+ Scrubbers can be run on a document in either a top-down traversal (the default) or bottom-up. Top-down scrubbers can optionally return `Scrubber::STOP` to terminate the traversal of a subtree. Read below and in the `Loofah::Scrubber` class for more detailed usage.
198
203
 
199
204
  Here's an XML example:
200
205
 
@@ -211,10 +216,10 @@ Loofah.xml_document(File.read('plague.xml')).scrub!(bring_out_your_dead)
211
216
 
212
217
  ### Built-In HTML Scrubbers
213
218
 
214
- Loofah comes with a set of sanitizing scrubbers that use HTML5lib's
215
- safelist algorithm:
219
+ Loofah comes with a set of sanitizing scrubbers that use `html5lib`'s safelist algorithm:
216
220
 
217
221
  ``` ruby
222
+ doc = Loofah.html5_document(input)
218
223
  doc.scrub!(:strip) # replaces unknown/unsafe tags with their inner text
219
224
  doc.scrub!(:prune) # removes unknown/unsafe tags and their children
220
225
  doc.scrub!(:escape) # escapes unknown/unsafe tags, like this: &lt;script&gt;
@@ -222,14 +227,17 @@ doc.scrub!(:whitewash) # removes unknown/unsafe/namespaced tags and their chi
222
227
  # and strips all node attributes
223
228
  ```
224
229
 
225
- Loofah also comes with some common transformation tasks:
230
+ Loofah also comes with some common transformation tasks:
226
231
 
227
232
  ``` ruby
228
- doc.scrub!(:nofollow) # adds rel="nofollow" attribute to links
233
+ doc.scrub!(:nofollow) # adds rel="nofollow" attribute to links
234
+ doc.scrub!(:noopener) # adds rel="noopener" attribute to links
235
+ doc.scrub!(:noreferrer) # adds rel="noreferrer" attribute to links
229
236
  doc.scrub!(:unprintable) # removes unprintable characters from text nodes
237
+ doc.scrub!(:targetblank) # adds target="_blank" attribute to links
230
238
  ```
231
239
 
232
- See Loofah::Scrubbers for more details and example usage.
240
+ See `Loofah::Scrubbers` for more details and example usage.
233
241
 
234
242
 
235
243
  ### Chaining Scrubbers
@@ -237,7 +245,7 @@ See Loofah::Scrubbers for more details and example usage.
237
245
  You can chain scrubbers:
238
246
 
239
247
  ``` ruby
240
- Loofah.fragment("<span>hello</span> <script>alert('OHAI')</script>") \
248
+ Loofah.html5_fragment("<span>hello</span> <script>alert('OHAI')</script>") \
241
249
  .scrub!(:prune) \
242
250
  .scrub!(span2div).to_s
243
251
  # => "<div>hello</div> "
@@ -245,21 +253,26 @@ Loofah.fragment("<span>hello</span> <script>alert('OHAI')</script>") \
245
253
 
246
254
  ### Shorthand
247
255
 
248
- The class methods Loofah.scrub_fragment and Loofah.scrub_document are
249
- shorthand.
256
+ The class methods `Loofah.scrub_html5_fragment` and `Loofah.scrub_html5_document` (and the corresponding HTML4 methods) are shorthand.
257
+
258
+ These methods:
250
259
 
251
260
  ``` ruby
252
- Loofah.scrub_fragment(unsafe_html, :prune)
253
- Loofah.scrub_document(unsafe_html, :prune)
261
+ Loofah.scrub_html5_fragment(unsafe_html, :prune)
262
+ Loofah.scrub_html5_document(unsafe_html, :prune)
263
+ Loofah.scrub_html4_fragment(unsafe_html, :prune)
264
+ Loofah.scrub_html4_document(unsafe_html, :prune)
254
265
  Loofah.scrub_xml_fragment(bad_xml, custom_scrubber)
255
266
  Loofah.scrub_xml_document(bad_xml, custom_scrubber)
256
267
  ```
257
268
 
258
- are the same thing as (and arguably semantically clearer than):
269
+ do the same thing as (and arguably semantically clearer than):
259
270
 
260
271
  ``` ruby
261
- Loofah.fragment(unsafe_html).scrub!(:prune)
262
- Loofah.document(unsafe_html).scrub!(:prune)
272
+ Loofah.html5_fragment(unsafe_html).scrub!(:prune)
273
+ Loofah.html5_document(unsafe_html).scrub!(:prune)
274
+ Loofah.html4_fragment(unsafe_html).scrub!(:prune)
275
+ Loofah.html4_document(unsafe_html).scrub!(:prune)
263
276
  Loofah.xml_fragment(bad_xml).scrub!(custom_scrubber)
264
277
  Loofah.xml_document(bad_xml).scrub!(custom_scrubber)
265
278
  ```
@@ -267,10 +280,9 @@ Loofah.xml_document(bad_xml).scrub!(custom_scrubber)
267
280
 
268
281
  ### View Helpers
269
282
 
270
- Loofah has two "view helpers": Loofah::Helpers.sanitize and
271
- Loofah::Helpers.strip_tags, both of which are drop-in replacements for
272
- the Rails ActionView helpers of the same name.
273
- These are no longer required automatically. You must require `loofah/helpers`.
283
+ Loofah has two "view helpers": `Loofah::Helpers.sanitize` and `Loofah::Helpers.strip_tags`, both of which are drop-in replacements for the Rails Action View helpers of the same name.
284
+
285
+ These are not required automatically. You must require `loofah/helpers` to use them.
274
286
 
275
287
 
276
288
  ## Requirements
@@ -282,7 +294,11 @@ These are no longer required automatically. You must require `loofah/helpers`.
282
294
 
283
295
  Unsurprisingly:
284
296
 
285
- * gem install loofah
297
+ > gem install loofah
298
+
299
+ Requirements:
300
+
301
+ * Ruby >= 2.5
286
302
 
287
303
 
288
304
  ## Support
@@ -296,8 +312,6 @@ And the mailing list is on Google Groups:
296
312
  * Mail: loofah-talk@googlegroups.com
297
313
  * Archive: https://groups.google.com/forum/#!forum/loofah-talk
298
314
 
299
- And the IRC channel is \#loofah on freenode.
300
-
301
315
  Consider subscribing to [Tidelift][tidelift] which provides license assurances and timely security notifications for your open source dependencies, including Loofah. [Tidelift][tidelift] subscriptions also help the Loofah maintainers fund our [automated testing](https://ci.nokogiri.org) which in turn allows us to ship releases, bugfixes, and security updates more often.
302
316
 
303
317
  [tidelift]: https://tidelift.com/subscription/pkg/rubygems-loofah?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise
@@ -308,26 +322,12 @@ Consider subscribing to [Tidelift][tidelift] which provides license assurances a
308
322
  See [`SECURITY.md`](SECURITY.md) for vulnerability reporting details.
309
323
 
310
324
 
311
- ### "Secure by Default"
312
-
313
- Some tools may incorrectly report Loofah as a potential security
314
- vulnerability.
315
-
316
- Loofah depends on Nokogiri, and it's _possible_ to use Nokogiri in a
317
- dangerous way (by enabling its DTDLOAD option and disabling its NONET
318
- option). This specifically allows the opportunity for an XML External
319
- Entity (XXE) vulnerability if the XML data is untrusted.
320
-
321
- However, Loofah __never enables this Nokogiri configuration__; Loofah
322
- never enables DTDLOAD, and it never disables NONET, thereby protecting
323
- you by default from this XXE vulnerability.
324
-
325
-
326
325
  ## Related Links
327
326
 
327
+ * loofah-activerecord: https://github.com/flavorjones/loofah-activerecord
328
328
  * Nokogiri: http://nokogiri.org
329
329
  * libxml2: http://xmlsoft.org
330
- * html5lib: https://code.google.com/p/html5lib
330
+ * html5lib: https://github.com/html5lib/
331
331
 
332
332
 
333
333
  ## Authors
@@ -337,26 +337,69 @@ you by default from this XXE vulnerability.
337
337
 
338
338
  Featuring code contributed by:
339
339
 
340
- * Aaron Patterson
341
- * John Barnette
342
- * Josh Owens
343
- * Paul Dix
344
- * Luke Melia
340
+ * [@flavorjones](https://github.com/flavorjones)
341
+ * [@brynary](https://github.com/brynary)
342
+ * [@olleolleolle](https://github.com/olleolleolle)
343
+ * [@JuanitoFatas](https://github.com/JuanitoFatas)
344
+ * [@kaspth](https://github.com/kaspth)
345
+ * [@tenderlove](https://github.com/tenderlove)
346
+ * [@ktdreyer](https://github.com/ktdreyer)
347
+ * [@orien](https://github.com/orien)
348
+ * [@asok](https://github.com/asok)
349
+ * [@junaruga](https://github.com/junaruga)
350
+ * [@MothOnMars](https://github.com/MothOnMars)
351
+ * [@nick-desteffen](https://github.com/nick-desteffen)
352
+ * [@NikoRoberts](https://github.com/NikoRoberts)
353
+ * [@trans](https://github.com/trans)
354
+ * [@andreynering](https://github.com/andreynering)
355
+ * [@aried3r](https://github.com/aried3r)
356
+ * [@baopham](https://github.com/baopham)
357
+ * [@batter](https://github.com/batter)
358
+ * [@brendon](https://github.com/brendon)
359
+ * [@cjba7](https://github.com/cjba7)
360
+ * [@christiankisssner](https://github.com/christiankisssner)
361
+ * [@dacort](https://github.com/dacort)
362
+ * [@danfstucky](https://github.com/danfstucky)
363
+ * [@david-a-wheeler](https://github.com/david-a-wheeler)
364
+ * [@dharamgollapudi](https://github.com/dharamgollapudi)
365
+ * [@georgeclaghorn](https://github.com/georgeclaghorn)
366
+ * [@gogainda](https://github.com/gogainda)
367
+ * [@jaredbeck](https://github.com/jaredbeck)
368
+ * [@ThatHurleyGuy](https://github.com/ThatHurleyGuy)
369
+ * [@jstorimer](https://github.com/jstorimer)
370
+ * [@jbarnette](https://github.com/jbarnette)
371
+ * [@queso](https://github.com/queso)
372
+ * [@technicalpickles](https://github.com/technicalpickles)
373
+ * [@kyoshidajp](https://github.com/kyoshidajp)
374
+ * [@kristianfreeman](https://github.com/kristianfreeman)
375
+ * [@louim](https://github.com/louim)
376
+ * [@mrpasquini](https://github.com/mrpasquini)
377
+ * [@olivierlacan](https://github.com/olivierlacan)
378
+ * [@pauldix](https://github.com/pauldix)
379
+ * [@sampokuokkanen](https://github.com/sampokuokkanen)
380
+ * [@stefannibrasil](https://github.com/stefannibrasil)
381
+ * [@tastycode](https://github.com/tastycode)
382
+ * [@vipulnsward](https://github.com/vipulnsward)
383
+ * [@joncalhoun](https://github.com/joncalhoun)
384
+ * [@ahorek](https://github.com/ahorek)
385
+ * [@rmacklin](https://github.com/rmacklin)
386
+ * [@y-yagi](https://github.com/y-yagi)
387
+ * [@lazyatom](https://github.com/lazyatom)
345
388
 
346
389
  And a big shout-out to Corey Innis for the name, and feedback on the API.
347
390
 
348
391
 
349
392
  ## Thank You
350
393
 
351
- The following people have generously funded Loofah:
394
+ The following people have generously funded Loofah with financial sponsorship:
352
395
 
353
396
  * Bill Harding
397
+ * [Sentry](https://sentry.io/) @getsentry
354
398
 
355
399
 
356
400
  ## Historical Note
357
401
 
358
- This library was formerly known as Dryopteris, which was a very bad
359
- name that nobody could spell properly.
402
+ This library was once named "Dryopteris", which was a very bad name that nobody could spell properly.
360
403
 
361
404
 
362
405
  ## License