sanitize 6.1.3 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{HISTORY.md → CHANGELOG.md} +50 -14
- data/LICENSE +3 -1
- data/README.md +130 -239
- data/lib/sanitize/config/basic.rb +15 -15
- data/lib/sanitize/config/default.rb +45 -45
- data/lib/sanitize/config/relaxed.rb +136 -32
- data/lib/sanitize/config/restricted.rb +2 -2
- data/lib/sanitize/config.rb +12 -14
- data/lib/sanitize/css.rb +403 -308
- data/lib/sanitize/transformers/clean_cdata.rb +9 -9
- data/lib/sanitize/transformers/clean_comment.rb +9 -9
- data/lib/sanitize/transformers/clean_css.rb +59 -55
- data/lib/sanitize/transformers/clean_doctype.rb +15 -15
- data/lib/sanitize/transformers/clean_element.rb +219 -237
- data/lib/sanitize/version.rb +3 -1
- data/lib/sanitize.rb +38 -38
- metadata +15 -56
- data/test/common.rb +0 -3
- data/test/test_clean_comment.rb +0 -47
- data/test/test_clean_css.rb +0 -67
- data/test/test_clean_doctype.rb +0 -71
- data/test/test_clean_element.rb +0 -552
- data/test/test_config.rb +0 -65
- data/test/test_malicious_css.rb +0 -55
- data/test/test_malicious_html.rb +0 -339
- data/test/test_parser.rb +0 -75
- data/test/test_sanitize.rb +0 -197
- data/test/test_sanitize_css.rb +0 -433
- data/test/test_transformers.rb +0 -230
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 694fdddd1e40857325f7fac61ee5679e6a9fca926413c1b035062ab7449b92c7
|
|
4
|
+
data.tar.gz: 426f1b4ece2fe0514139b661ba77ca7b9a6196481a0759a3ac81a9f446996e3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e58a303bb8a1285fbc75ab93acfd896444dc125d3b9b13884868366720bc451e5c69409b9a852014394604bc932e0ffbeeb7c1b7192eb3cd0a673ec10a79df2
|
|
7
|
+
data.tar.gz: 8a4b8ca81da4bc4bb070941fab4b08f8e6d36a10487d0d90820e762155fe5717acfbc919c2676650d490cd7d9cac82f7a2f4ec21bc0f373f837938a23a670d6d
|
data/{HISTORY.md → CHANGELOG.md}
RENAMED
|
@@ -1,4 +1,42 @@
|
|
|
1
|
-
# Sanitize
|
|
1
|
+
# Sanitize Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to Sanitize are documented in this file. The format (since version 7.0.0) is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
|
+
|
|
5
|
+
## 7.0.1 (2026-10-21)
|
|
6
|
+
|
|
7
|
+
### Security
|
|
8
|
+
|
|
9
|
+
- CSS properties that contain a `{}` block anywhere in their value are now removed. Browsers that support [CSS nesting](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting) reparse an invalid declaration containing a `{}` block as a nested style rule, so a value like `color:hover{position:fixed}` could previously be used to smuggle disallowed properties and URLs past Sanitize in a stylesheet or `<style>` element. (GHSA-wgw9-qhqg-8hv5)
|
|
10
|
+
|
|
11
|
+
- The contents of at-rules such as `@media` and `@supports` that appear in a list of declarations (inside a style rule, inside an at-rule like `@font-face`, or in CSS sanitized with `Sanitize::CSS.properties`) are now sanitized as declarations rather than as rules, matching how browsers that support CSS nesting parse them. Previously, a stylesheet like `p{@media all{position:fixed;a{}}}` could be used to smuggle disallowed properties and URLs past Sanitize, since Sanitize treated `position:fixed;a` as a style rule's selector. The same was true of CSS sanitized with `Sanitize::CSS.properties` if the result was later embedded in a style rule. Style rules nested inside these at-rules are now removed, just as style rules nested directly inside other style rules already were. (GHSA-wgw9-qhqg-8hv5)
|
|
12
|
+
|
|
13
|
+
- CSS properties, style rules, and at-rules that contain blocks or functions nested more deeply than Crass's maximum nesting depth (25 levels by default) are now removed. (GHSA-wgw9-qhqg-8hv5)
|
|
14
|
+
|
|
15
|
+
- Hardened CSS sanitization against tokenizer differentials involving bad URLs. CSS properties that contain a bad URL anywhere inside a simple block (such as `[...]` or `(...)`) are now removed, as are style rules whose selectors contain a bad URL and at-rules whose preludes contain a bad URL. URLs inside simple blocks are now also validated against the configured protocol allowlist. Previously, a bug in Crass (fixed in Crass 1.0.8) could be exploited to smuggle CSS declarations, rules, or at-rules past Sanitize by hiding them in a bad URL in one of these locations.
|
|
16
|
+
|
|
17
|
+
- CSS style rules whose selectors contain a semicolon are now removed, as a defense in depth measure. A semicolon is never valid in a selector, but when a style rule appears where a browser that supports CSS nesting expects declarations, the browser treats everything before the semicolon as a declaration. This could be used to smuggle disallowed properties past `Sanitize::CSS.tree!` when it was given a list of declarations rather than a list of rules (though this isn't something Sanitize itself does).
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Removed an unused `require "cgi"` that caused a warning on Ruby 4.0, since the CGI library is no longer part of Ruby's standard library.
|
|
22
|
+
|
|
23
|
+
## 7.0.0 (2024-12-29)
|
|
24
|
+
|
|
25
|
+
Sanitize has no breaking API changes in this release, but the major version number has been incremented because we've dropped support for end-of-life versions of Ruby. As long as you're using Ruby 3.1.0 or later, this should be a painless upgrade!
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- Added over 100 new CSS properties to the relaxed config, representing all properties that are listed with a status of "Working Draft" or better in the latest [W3C "All Properties" list](https://www.w3.org/Style/CSS/all-properties.en.html).
|
|
30
|
+
|
|
31
|
+
- Added the `@container` CSS at-rule to the relaxed config.
|
|
32
|
+
|
|
33
|
+
- Added the `-webkit-text-fill-color` CSS property to the relaxed config. [@radar - #244](https://github.com/rgrove/sanitize/pull/244)
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- Ruby 3.1.0 is now the oldest supported Ruby version.
|
|
38
|
+
|
|
39
|
+
- Sanitize now requires Nokogiri 1.16.8 or higher.
|
|
2
40
|
|
|
3
41
|
## 6.1.3 (2024-08-14)
|
|
4
42
|
|
|
@@ -279,8 +317,6 @@ review the changes below carefully.
|
|
|
279
317
|
Many thanks to the Shopify Application Security Team for responsibly reporting
|
|
280
318
|
this issue.
|
|
281
319
|
|
|
282
|
-
[176]:https://github.com/rgrove/sanitize/issues/176
|
|
283
|
-
|
|
284
320
|
## 4.6.2 (2018-03-19)
|
|
285
321
|
|
|
286
322
|
* Reduced string allocations to optimize memory usage. [@janklimo - #175][175]
|
|
@@ -618,7 +654,7 @@ Sanitize.fragment(html, Sanitize::Config.merge(Sanitize::Config::BASIC,
|
|
|
618
654
|
## 2.0.4 (2013-06-12)
|
|
619
655
|
|
|
620
656
|
* Added `Sanitize.clean_document`, which sanitizes a full HTML document rather
|
|
621
|
-
than just a fragment. [Ben Anderson]
|
|
657
|
+
than just a fragment. \[Ben Anderson]
|
|
622
658
|
|
|
623
659
|
* Nokogiri dependency bumped to 1.6.x.
|
|
624
660
|
|
|
@@ -641,7 +677,7 @@ Sanitize.fragment(html, Sanitize::Config.merge(Sanitize::Config::BASIC,
|
|
|
641
677
|
## 2.0.1 (2011-03-16)
|
|
642
678
|
|
|
643
679
|
* Updated the protocol regex to anchor at the beginning of the string rather
|
|
644
|
-
than the beginning of a line. [Eaden McKee]
|
|
680
|
+
than the beginning of a line. \[Eaden McKee]
|
|
645
681
|
|
|
646
682
|
|
|
647
683
|
## 2.0.0 (2011-01-15)
|
|
@@ -687,7 +723,7 @@ Sanitize.fragment(html, Sanitize::Config.merge(Sanitize::Config::BASIC,
|
|
|
687
723
|
remove the contents of all non-allowlisted elements in addition to the
|
|
688
724
|
elements themselves. If set to an array of element names, Sanitize will
|
|
689
725
|
remove the contents of only those elements (when filtered), and leave the
|
|
690
|
-
contents of other filtered elements. [Thanks to Rafael Souza for the array
|
|
726
|
+
contents of other filtered elements. \[Thanks to Rafael Souza for the array
|
|
691
727
|
option]
|
|
692
728
|
|
|
693
729
|
* Added an `:output_encoding` config setting to allow the character encoding
|
|
@@ -712,27 +748,27 @@ Sanitize.fragment(html, Sanitize::Config.merge(Sanitize::Config::BASIC,
|
|
|
712
748
|
* Added `Sanitize.clean_node!`, which sanitizes a `Nokogiri::XML::Node` and
|
|
713
749
|
all its children.
|
|
714
750
|
|
|
715
|
-
* Added elements `<h1>` through `<h6>` to the Relaxed allowlist. [Suggested by
|
|
751
|
+
* Added elements `<h1>` through `<h6>` to the Relaxed allowlist. \[Suggested by
|
|
716
752
|
David Reese]
|
|
717
753
|
|
|
718
754
|
|
|
719
755
|
## 1.1.0 (2009-10-11)
|
|
720
756
|
|
|
721
|
-
* Migrated from Hpricot to Nokogiri. Requires libxml2 >= 2.7.2 [Adam Hooper]
|
|
757
|
+
* Migrated from Hpricot to Nokogiri. Requires libxml2 >= 2.7.2 \[Adam Hooper]
|
|
722
758
|
|
|
723
759
|
* Added an `:output` config setting to allow the output format to be
|
|
724
760
|
specified. Supported formats are `:xhtml` (the default) and `:html` (which
|
|
725
761
|
outputs HTML4).
|
|
726
762
|
|
|
727
763
|
* Changed protocol regex to ensure Sanitize doesn't kill URLs with colons in
|
|
728
|
-
path segments. [Peter Cooper]
|
|
764
|
+
path segments. \[Peter Cooper]
|
|
729
765
|
|
|
730
766
|
|
|
731
767
|
## 1.0.8 (2009-04-23)
|
|
732
768
|
|
|
733
769
|
* Added a workaround for an Hpricot bug that prevents attribute names from
|
|
734
770
|
being downcased in recent versions of Hpricot. This was exploitable to
|
|
735
|
-
prevent non-allowlisted protocols from being cleaned. [Reported by Ben
|
|
771
|
+
prevent non-allowlisted protocols from being cleaned. \[Reported by Ben
|
|
736
772
|
Wanicur]
|
|
737
773
|
|
|
738
774
|
|
|
@@ -741,7 +777,7 @@ Sanitize.fragment(html, Sanitize::Config.merge(Sanitize::Config::BASIC,
|
|
|
741
777
|
* Requires Hpricot 0.8.1+, which is finally compatible with Ruby 1.9.1.
|
|
742
778
|
|
|
743
779
|
* Fixed a bug that caused named character entities containing digits (like
|
|
744
|
-
`²`) to be escaped when they shouldn't have been. [Reported by
|
|
780
|
+
`²`) to be escaped when they shouldn't have been. \[Reported by
|
|
745
781
|
Sebastian Steinmetz]
|
|
746
782
|
|
|
747
783
|
|
|
@@ -756,14 +792,14 @@ Sanitize.fragment(html, Sanitize::Config.merge(Sanitize::Config::BASIC,
|
|
|
756
792
|
problems in IE6.
|
|
757
793
|
|
|
758
794
|
* You can now specify the symbol `:all` in place of an element name in the
|
|
759
|
-
attributes config hash to allow certain attributes on all elements. [Thanks
|
|
795
|
+
attributes config hash to allow certain attributes on all elements. \[Thanks
|
|
760
796
|
to Mutwin Kraus]
|
|
761
797
|
|
|
762
798
|
|
|
763
799
|
## 1.0.5 (2009-02-05)
|
|
764
800
|
|
|
765
801
|
* Fixed a bug introduced in version 1.0.3 that prevented non-allowlisted
|
|
766
|
-
protocols from being cleaned when relative URLs were allowed. [Reported by
|
|
802
|
+
protocols from being cleaned when relative URLs were allowed. \[Reported by
|
|
767
803
|
Dev Purkayastha]
|
|
768
804
|
|
|
769
805
|
* Fixed "undefined method `parent='" exceptions caused by parser changes in
|
|
@@ -774,7 +810,7 @@ Sanitize.fragment(html, Sanitize::Config.merge(Sanitize::Config::BASIC,
|
|
|
774
810
|
|
|
775
811
|
* Fixed a bug that made it possible to sneak a non-allowlisted element through
|
|
776
812
|
by repeating it several times in a row. All versions of Sanitize prior to
|
|
777
|
-
1.0.4 are vulnerable. [Reported by Cristobal]
|
|
813
|
+
1.0.4 are vulnerable. \[Reported by Cristobal]
|
|
778
814
|
|
|
779
815
|
|
|
780
816
|
## 1.0.3 (2009-01-15)
|
data/LICENSE
CHANGED