# Sanitize History ## 4.6.6 (2018-07-23) * Improved performance and memory usage by optimizing `Sanitize#transform_node!` [@stanhu - #183][183] [183]:https://github.com/rgrove/sanitize/pull/183 ## 4.6.5 (2018-05-16) * Improved performance slightly by tweaking the order of built-in transformers. [@rafbm - #180][180] [180]:https://github.com/rgrove/sanitize/pull/180 ## 4.6.4 (2018-03-20) * Fixed: A change introduced in 4.6.2 broke certain transformers that relied on being able to mutate the name of an HTML node. That change has been reverted and a test has been added to cover this case. [@zetter - #177][177] [177]:https://github.com/rgrove/sanitize/issues/177 ## 4.6.3 (2018-03-19) * [CVE-2018-3740][176]: Fixed an HTML injection vulnerability that could allow XSS. When Sanitize <= 4.6.2 is used in combination with libxml2 >= 2.9.2, a specially crafted HTML fragment can cause libxml2 to generate improperly escaped output, allowing non-whitelisted attributes to be used on whitelisted elements. Sanitize now performs additional escaping on affected attributes to prevent this. Many thanks to the Shopify Application Security Team for responsibly reporting this issue. [176]:https://github.com/rgrove/sanitize/issues/176 ## 4.6.2 (2018-03-19) * Reduced string allocations to optimize memory usage. [@janklimo - #175][175] [175]:https://github.com/rgrove/sanitize/pull/175 ## 4.6.1 (2018-03-15) * Added support for frozen string literals in Ruby 2.4+. [@flavorjones - #174][174] [174]:https://github.com/rgrove/sanitize/pull/174 ## 4.6.0 (2018-01-29) * Loosened the Nokogumbo dependency to allow installing semver-compatible versions greater than or equal to v1.4. [@rafbm - #171][171] [171]:https://github.com/rgrove/sanitize/pull/171 ## 4.5.0 (2017-06-04) * Added SVG-related CSS properties to the relaxed config. See [the diff][161] for the full list of added properties. [@louim - #161][161] * Fixed: Sanitize now strips null bytes (`\u0000`) before passing input to Nokogumbo, since they can cause recent versions to crash with a failed assertion in the Gumbo parser. [161]:https://github.com/rgrove/sanitize/pull/161 ## 4.4.0 (2016-09-29) * Added `srcset` to the attribute whitelist for `img` elements in the relaxed config. [@ejtttje - #156][156] [156]:https://github.com/rgrove/sanitize/pull/156 ## 4.3.0 (2016-09-20) * Methods can now be used as transformers. [@Skipants - #155][155] [155]:https://github.com/rgrove/sanitize/pull/155 ## 4.2.0 (2016-08-22) * Added `-webkit-font-smoothing` to the relaxed CSS config. [@louim - #154][154] * Fixed: Nokogumbo >=1.4.9 changed its behavior in a way that allowed invalid doctypes (like ``) when the `:allow_doctype` config setting was `true`. Invalid doctypes are now coerced to valid ones as they were prior to this Nokogumbo change. [154]:https://github.com/rgrove/sanitize/pull/154 ## 4.1.0 (2016-06-17) * Added a new CSS config setting, `:import_url_validator`. This is a Proc or other callable object that will be called with each `@import` URL, and should return `true` to allow the URL or `false` to remove it. [@nikz - #153][153] [153]:https://github.com/rgrove/sanitize/pull/153/ ## 4.0.1 (2015-12-09) * Unpinned the Nokogumbo dependency. [@rubys - #141][141] [141]:https://github.com/rgrove/sanitize/pull/141 ## 4.0.0 (2015-04-20) ### Potentially breaking changes * Added two new CSS config settings, `:at_rules_with_properties` and `:at_rules_with_styles`. These allow you to define which at-rules should be allowed to contain properties and which should be allowed to contain style rules. Previously this was hard-coded internally. [#111][111] The previous `:at_rules` setting still exists, and defines at-rules that may not have associated blocks, such as `@import`. If you have a custom config that contains an `:at_rules` setting, you may need to move rules can have blocks to either `:at_rules_with_properties` or `:at_rules_with_styles`. See Sanitize's relaxed config for an example. ### Other changes * Added full support for CSS `@page` rules in the relaxed config, including support for all page-margin box rules (such as `@top-left`, `@bottom-center`, etc.) * Added the following CSS at-rules to the relaxed config: - `@-moz-keyframes` - `@-o-keyframes` - `@-webkit-keyframes` - `@document` * Added a whole bunch of CSS properties to the relaxed config. View the complete list [here](https://gist.github.com/rgrove/044cc7e9a5b44f583c05). * Small performance improvements. * Fixed: Upgraded Crass to 1.0.2 to pick up a fix that affected the parsing of CSS `@page` rules. [111]:https://github.com/rgrove/sanitize/issues/111 ## 3.1.2 (2015-02-22) * Fixed: Deleting a node in a custom transformer could trigger a memory leak in Nokogiri if that node's children were later reparented, which the built-in CleanElement transformer did by default. The CleanElement transformer is now careful not to reparent the children of deleted nodes. [#129][129] [129]:https://github.com/rgrove/sanitize/issues/129 ## 3.1.1 (2015-02-04) * Fixed: `#document` and `#fragment` failed on frozen strings, and could unintentionally modify unfrozen strings if they used an encoding other than UTF-8 or if they contained characters not allowed in HTML. [@AnchorCat - #128][128] [128]:https://github.com/rgrove/sanitize/pull/128 ## 3.1.0 (2014-12-22) * Added the following CSS properties to the relaxed config. [@ehudc - #120][120] - `-moz-text-size-adjust` - `-ms-text-size-adjust` - `-webkit-text-size-adjust` - `text-size-adjust` * Updated Nokogumbo to 1.2.0 to pick up a fix for a Gumbo bug where the entity `Æ` left its semicolon behind when it was converted to a character during parsing. [#119][119] [119]:https://github.com/rgrove/sanitize/issues/119 [120]:https://github.com/rgrove/sanitize/pull/120 ## 3.0.4 (2014-12-12) * Fixed: Harmless whitespace preceding a URL protocol (such as " http://") caused the URL to be removed even when the protocol was whitelisted. [@benubois - #126][126] [126]:https://github.com/rgrove/sanitize/pull/126 ## 3.0.3 (2014-10-29) * Fixed: Some CSS selectors weren't parsed correctly inside the body of a `@media` block, causing them to be removed even when whitelist rules should have allowed them to remain. [#121][121] [121]:https://github.com/rgrove/sanitize/issues/121 ## 3.0.2 (2014-09-02) * Updated Nokogumbo to 1.1.12, because 1.1.11 silently reverted the change we were trying to pick up in the last release. Now issue [#114][114] is _actually_ fixed. ## 3.0.1 (2014-09-02) * Updated Nokogumbo to 1.1.11 to pick up a fix for a Gumbo bug in which certain HTML character entities, such as `Ö`, were parsed incorrectly, leaving the semicolon behind in the output. [#114][114] [114]:https://github.com/rgrove/sanitize/issues/114 ## 3.0.0 (2014-06-21) As of this version, Sanitize adheres strictly to the [SemVer 2.0.0][semver] versioning standard. This release contains API and output changes that are incompatible with previous releases, as indicated by the major version increment. [semver]:http://semver.org/ ### Backwards-incompatible changes * HTML is now parsed using Google's Gumbo HTML5 parser, which adheres to the HTML5 parsing spec and behaves much more like modern browser parsers than the previous libxml2-based parser. As a result, HTML output may differ from that of previous versions of Sanitize. * All transformers now traverse the document from the top down, starting with the first node, then its first child, and so on. The `:transformers_breadth` config has been removed, and old bottom-up transformers (the previous default) may need to be rewritten. * Sanitize's built-in configs are now deeply frozen to prevent people from modifying them (either accidentally or maliciously). To customize a built-in config, create a new copy using `Sanitize::Config.merge()`, like so: ```ruby Sanitize.fragment(html, Sanitize::Config.merge(Sanitize::Config::BASIC, :elements => Sanitize::Config::BASIC[:elements] + ['div', 'table'], :remove_contents => true )) ``` * The `clean!` and `clean_document!` methods were removed, since they weren't useful and tended to confuse people. * The `clean` method was renamed to `fragment` to more clearly indicate that its intended use is to sanitize an HTML fragment. * The `clean_document` method was renamed to `document`. * The `clean_node!` method was renamed to `node!`. * The `document` method now raises a `Sanitize::Error` if the `` element isn't whitelisted, rather than a `RuntimeError`. This error is also now raised regardless of the `:remove_contents` config setting. * The `:output` config has been removed. Output is now always HTML, not XHTML. * The `:output_encoding` config has been removed. Output is now always UTF-8. ### Other changes * Added advanced CSS sanitization support using [Crass][crass], which is fully compliant with the CSS Syntax Module Level 3 parsing spec. The contents of whitelisted `