loofah 2.21.4 → 2.23.0

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: 5bc700e0a8a523327ae05ebaace9741de9c00f165279a9525515c6c50699c0d9
4
- data.tar.gz: cc8db32a403e04256aad34637f0824b117159d357a4e180be1385b3998d90208
3
+ metadata.gz: 69d24833d5dac5e1845b35ab17eddb200056337faf201d91a88067f1000bdb95
4
+ data.tar.gz: 5c9939a49b3c05d69ba197a76d4f9118631be7110ced87b375113289f23493eb
5
5
  SHA512:
6
- metadata.gz: bda76a2e8ade5dd0461b3dca3386fb9a297fba1213a81ca404026fe17b33ab74fa4ed92916b11f921ac9e6b7bc77751e40ef7fabc706891d39e4e83cc091c17a
7
- data.tar.gz: 981e45721b457e5c00a4c68dac710f121e23e0f26d5a1c35fbb3958b0e2574c12065e0b5166d0b55b0d836e79762326af1039aa442347993bc22c95ce5dad5fa
6
+ metadata.gz: aed08cf6f2d7cd3ca89c475f40ff25affab14337ab7baf41e2ca7e157feb1e3ba13c97c693ee3a42417cc181136ca52c26d2c844fd35fd8de3d0e89893cdaf6e
7
+ data.tar.gz: a7d36d63f3825a2e5976038776ad68e6932cc473422909d49283fd426c143f743733a1e4f4fddea135c828bb7a2d3015fbd566f7b61ae5fb1bf35af2c5ce8e14
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.23.0 / 2024-10-24
4
+
5
+ ### Added
6
+
7
+ * Allow CSS property `min-width`. [#287] @lazyatom
8
+
9
+
10
+ ## 2.22.0 / 2023-11-13
11
+
12
+ ### Added
13
+
14
+ * A `:targetblank` HTML scrubber which ensures all hyperlinks have `target="_blank"`. [#275] @stefannibrasil and @thdaraujo
15
+ * A `:noreferrer` HTML scrubber which ensures all hyperlinks have `rel=noreferrer`, similar to the `:nofollow` and `:noopener` scrubbers. [#277] @wynksaiddestroy
16
+
17
+
3
18
  ## 2.21.4 / 2023-10-10
4
19
 
5
20
  ### Fixed
data/README.md CHANGED
@@ -29,6 +29,7 @@ Active Record extensions for HTML sanitization are available in the [`loofah-act
29
29
  * _Whitewash_ the markup, removing all attributes and namespaced nodes.
30
30
  * Other common HTML transformations are built-in:
31
31
  * Add the _nofollow_ attribute to all hyperlinks.
32
+ * Add the _target=\_blank_ attribute to all hyperlinks.
32
33
  * Remove _unprintable_ characters from text nodes.
33
34
  * Format markup as plain text, with (or without) sensible whitespace handling around block elements.
34
35
  * Replace Rails's `strip_tags` and `sanitize` view helper methods.
@@ -229,8 +230,11 @@ doc.scrub!(:whitewash) # removes unknown/unsafe/namespaced tags and their chi
229
230
  Loofah also comes with some common transformation tasks:
230
231
 
231
232
  ``` ruby
232
- 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
233
236
  doc.scrub!(:unprintable) # removes unprintable characters from text nodes
237
+ doc.scrub!(:targetblank) # adds target="_blank" attribute to links
234
238
  ```
235
239
 
236
240
  See `Loofah::Scrubbers` for more details and example usage.
@@ -333,20 +337,64 @@ See [`SECURITY.md`](SECURITY.md) for vulnerability reporting details.
333
337
 
334
338
  Featuring code contributed by:
335
339
 
336
- * Aaron Patterson
337
- * John Barnette
338
- * Josh Owens
339
- * Paul Dix
340
- * 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)
341
388
 
342
389
  And a big shout-out to Corey Innis for the name, and feedback on the API.
343
390
 
344
391
 
345
392
  ## Thank You
346
393
 
347
- The following people have generously funded Loofah:
394
+ The following people have generously funded Loofah with financial sponsorship:
348
395
 
349
396
  * Bill Harding
397
+ * [Sentry](https://sentry.io/) @getsentry
350
398
 
351
399
 
352
400
  ## Historical Note
@@ -663,6 +663,7 @@ module Loofah
663
663
  "list-style",
664
664
  "list-style-type",
665
665
  "max-width",
666
+ "min-width",
666
667
  "order",
667
668
  "overflow",
668
669
  "overflow-x",
@@ -61,6 +61,15 @@ module Loofah
61
61
  # => "ohai! <a href='http://www.myswarmysite.com/' rel="nofollow">I like your blog post</a>"
62
62
  #
63
63
  #
64
+ # === Loofah::Scrubbers::TargetBlank / scrub!(:targetblank)
65
+ #
66
+ # +:targetblank+ adds a target="_blank" attribute to all links
67
+ #
68
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
69
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:targetblank)
70
+ # => "ohai! <a href='http://www.myswarmysite.com/' target="_blank">I like your blog post</a>"
71
+ #
72
+ #
64
73
  # === Loofah::Scrubbers::NoOpener / scrub!(:noopener)
65
74
  #
66
75
  # +:noopener+ adds a rel="noopener" attribute to all links
@@ -69,6 +78,14 @@ module Loofah
69
78
  # Loofah.html5_fragment(link_farmers_markup).scrub!(:noopener)
70
79
  # => "ohai! <a href='http://www.myswarmysite.com/' rel="noopener">I like your blog post</a>"
71
80
  #
81
+ # === Loofah::Scrubbers::NoReferrer / scrub!(:noreferrer)
82
+ #
83
+ # +:noreferrer+ adds a rel="noreferrer" attribute to all links
84
+ #
85
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
86
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:noreferrer)
87
+ # => "ohai! <a href='http://www.myswarmysite.com/' rel="noreferrer">I like your blog post</a>"
88
+ #
72
89
  #
73
90
  # === Loofah::Scrubbers::Unprintable / scrub!(:unprintable)
74
91
  #
@@ -213,6 +230,33 @@ module Loofah
213
230
  end
214
231
  end
215
232
 
233
+ #
234
+ # === scrub!(:targetblank)
235
+ #
236
+ # +:targetblank+ adds a target="_blank" attribute to all links.
237
+ # If there is a target already set, replaces it with target="_blank".
238
+ #
239
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
240
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:targetblank)
241
+ # => "ohai! <a href='http://www.myswarmysite.com/' target="_blank">I like your blog post</a>"
242
+ #
243
+ # On modern browsers, setting target="_blank" on anchor elements implicitly provides the same
244
+ # behavior as setting rel="noopener".
245
+ #
246
+ class TargetBlank < Scrubber
247
+ def initialize # rubocop:disable Lint/MissingSuper
248
+ @direction = :top_down
249
+ end
250
+
251
+ def scrub(node)
252
+ return CONTINUE unless (node.type == Nokogiri::XML::Node::ELEMENT_NODE) && (node.name == "a")
253
+
254
+ node.set_attribute("target", "_blank")
255
+
256
+ STOP
257
+ end
258
+ end
259
+
216
260
  #
217
261
  # === scrub!(:noopener)
218
262
  #
@@ -235,6 +279,28 @@ module Loofah
235
279
  end
236
280
  end
237
281
 
282
+ #
283
+ # === scrub!(:noreferrer)
284
+ #
285
+ # +:noreferrer+ adds a rel="noreferrer" attribute to all links
286
+ #
287
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
288
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:noreferrer)
289
+ # => "ohai! <a href='http://www.myswarmysite.com/' rel="noreferrer">I like your blog post</a>"
290
+ #
291
+ class NoReferrer < Scrubber
292
+ def initialize # rubocop:disable Lint/MissingSuper
293
+ @direction = :top_down
294
+ end
295
+
296
+ def scrub(node)
297
+ return CONTINUE unless (node.type == Nokogiri::XML::Node::ELEMENT_NODE) && (node.name == "a")
298
+
299
+ append_attribute(node, "rel", "noreferrer")
300
+ STOP
301
+ end
302
+ end
303
+
238
304
  # This class probably isn't useful publicly, but is used for #to_text's current implemention
239
305
  class NewlineBlockElements < Scrubber # :nodoc:
240
306
  def initialize # rubocop:disable Lint/MissingSuper
@@ -292,6 +358,8 @@ module Loofah
292
358
  strip: Strip,
293
359
  nofollow: NoFollow,
294
360
  noopener: NoOpener,
361
+ noreferrer: NoReferrer,
362
+ targetblank: TargetBlank,
295
363
  newline_block_elements: NewlineBlockElements,
296
364
  unprintable: Unprintable,
297
365
  }
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Loofah
4
4
  # The version of Loofah you are using
5
- VERSION = "2.21.4"
5
+ VERSION = "2.23.0"
6
6
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loofah
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.21.4
4
+ version: 2.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
8
8
  - Bryan Helmkamp
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-10 00:00:00.000000000 Z
12
+ date: 2024-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: crass
@@ -82,7 +82,7 @@ metadata:
82
82
  bug_tracker_uri: https://github.com/flavorjones/loofah/issues
83
83
  changelog_uri: https://github.com/flavorjones/loofah/blob/main/CHANGELOG.md
84
84
  documentation_uri: https://www.rubydoc.info/gems/loofah/
85
- post_install_message:
85
+ post_install_message:
86
86
  rdoc_options: []
87
87
  require_paths:
88
88
  - lib
@@ -97,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.5.0.dev
101
- signing_key:
100
+ rubygems_version: 3.5.22
101
+ signing_key:
102
102
  specification_version: 4
103
103
  summary: Loofah is a general library for manipulating and transforming HTML/XML documents
104
104
  and fragments, built on top of Nokogiri.