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, fixes #271]
- Quash "instance variable not initialized" warning in Ruby < 3.0. [#268] (Thanks, @dharamgollapudi!)
- 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 aNameError
exception. [#266]
- Don't define
HTML5::Document
andHTML5::DocumentFragment
when Nokogiri is< 1.14
. In 2.21.0 these classes were defined wheneverNokogiri::HTML5
was defined, but Nokogiri v1.12 and v1.13 do not support Loofah subclassing properly.
Classes Loofah::HTML5::Document
and Loofah::HTML5::DocumentFragment
are introduced, along with helper methods:
Loofah.html5_document
Loofah.html5_fragment
Loofah.scrub_html5_document
Loofah.scrub_html5_fragment
These classes and methods use Nokogiri's HTML5 parser to ensure modern web standards are used.
⚠ HTML5 functionality is only available with Nokogiri v1.14.0 and higher.
⚠ HTML5 functionality is not available for JRuby. Please see this upstream Nokogiri issue if you're interested in helping implement and support HTML5 support.
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.
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?
.
Future releases of Nokogiri may deprecate HTML
classes and methods or otherwise change this behavior, so please start using HTML4
in place of HTML
.
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.
- Allow SVG attributes
color-profile
,cursor
,filter
,marker
, andmask
. [#246] - Allow SVG elements
altGlyph
,cursor
,feImage
,pattern
, andtref
. [#246] - Allow protocols
fax
andmodem
. [#255] (Thanks, @cjba7!)
- Address CVE-2022-23514, inefficient regular expression complexity. See GHSA-486f-hjj9-9vhh for more information.
- Address CVE-2022-23515, improper neutralization of data URIs. See GHSA-228g-948r-83gx for more information.
- Address CVE-2022-23516, uncontrolled recursion. See GHSA-3x8r-x6xp-q4vm for more information.
- Allow SVG 1.0 color keyword names in CSS attributes. These colors are part of the CSS Color Module Level 3 recommendation released 2022-01-18. [#243]
- Allow ARIA attributes. [#232, #233] (Thanks, @nick-desteffen!)
- Allow MathML elements
menclose
andms
, and MathML attributesdir
,href
,lquote
,mathsize
,notation
, andrquote
. [#231] (Thanks, @nick-desteffen!)
- The
#to_text
method onLoofah::HTML::{Document,DocumentFragment}
replaces<br>
line break elements with a newline. [#225]
- Loofah::HTML::DocumentFragment#text no longer serializes top-level comment children. [#221]
- Support empty HTML5 data attributes. [#215]
- Allow HTML5 element
wbr
. - Allow all CSS property values for
border-collapse
. [#201]
- Deprecating
Loofah::HTML5::SafeList::VOID_ELEMENTS
which is not a canonical list of void HTML4 or HTML5 elements. - Removed some elements from
Loofah::HTML5::SafeList::VOID_ELEMENTS
that either are not acceptable elements or aren't considered "void" by libxml2.
- Allow CSS properties
overflow-x
andoverflow-y
. [#206] (Thanks, @sampokuokkanen!)
- Fix a regression in v2.9.0 which inappropriately removed CSS properties with quoted string values. [#202]
- Allow CSS properties
order
,flex-direction
,flex-grow
,flex-wrap
,flex-shrink
,flex-flow
,flex-basis
,flex
,justify-content
,align-self
,align-items
, andalign-content
. [#197] (Thanks, @miguelperez!)
- Allow CSS properties
page-break-before
,page-break-inside
, andpage-break-after
. [#190] (Thanks, @ahorek!)
- Allow CSS
border-style
keywords. [#188] (Thanks, @tarcisiozf!)
- Allow more CSS length units: "ch", "vw", "vh", "Q", "lh", "vmin", "vmax". [#178] (Thanks, @JuanitoFatas!)
- Remove comments from
Loofah::HTML::Document
s that exist outside thehtml
element. [#80]
- Gem metadata being set [#181] (Thanks, @JuanitoFatas!)
- Test files removed from gem file [#180,#166,#159] (Thanks, @JuanitoFatas and @greysteil!)
- Allow CSS property
max-width
[#175] (Thanks, @bchaney!) - Allow CSS sizes expressed in
rem
[#176, #177] - Add
frozen_string_literal: true
magic comment to alllib
files. [#118]
Address CVE-2019-15587: Unsanitized JavaScript may occur in sanitized output when a crafted SVG element is republished.
This CVE's public notice is at #171
- Expand set of allowed protocols to include
tel:
andline:
. [#104, #147] - Expand set of allowed CSS functions. [related to #122]
- Allow greater precision in shorthand CSS values. [#149] (Thanks, @danfstucky!)
- Allow CSS property
list-style
[#162] (Thanks, @jaredbeck!) - Allow CSS keywords
thick
andthin
[#168] (Thanks, @georgeclaghorn!) - Allow HTML property
contenteditable
[#167] (Thanks, @andreynering!)
- CSS hex values are no longer limited to lowercase hex. Previously uppercase hex were scrubbed. [#165] (Thanks, @asok!)
The following method and constants are hereby deprecated, and will be completely removed in a future release:
- Deprecate
Loofah::Helpers::ActionView.white_list_sanitizer
, please useLoofah::Helpers::ActionView.safe_list_sanitizer
instead. - Deprecate
Loofah::Helpers::ActionView::WhiteListSanitizer
, please useLoofah::Helpers::ActionView::SafeListSanitizer
instead. - Deprecate
Loofah::HTML5::WhiteList
, please useLoofah::HTML5::SafeList
instead.
Thanks to @JuanitoFatas for submitting these changes in #164 and for making the language used in Loofah more inclusive.
Address CVE-2018-16468: Unsanitized JavaScript may occur in sanitized output when a crafted SVG element is republished.
This CVE's public notice is at #154
The mailing list is now on Google Groups #146:
This change was made because librelist no longer appears to be maintained.
Make public Loofah::HTML5::Scrub.force_correct_attribute_escaping!
,
which was previously a private method. This is so that downstream gems
(like rails-html-sanitizer) can use this logic directly for their own
attribute scrubbers should they need to address CVE-2018-8048.
Addresses CVE-2018-8048. Loofah allowed non-whitelisted attributes to be present in sanitized output when input with specially-crafted HTML fragments.
This CVE's public notice is at #144
- Support HTML5
<main>
tag. #133 (Thanks, @MothOnMars!) - Recognize HTML5 block elements. #136 (Thanks, @MothOnMars!)
- Support SVG
<symbol>
tag. #131 (Thanks, @baopham!) - Support for whitelisting CSS functions, initially just
calc
andrgb
. #122/#123/#129 (Thanks, @NikoRoberts!) - Whitelist CSS property
list-style-type
. #68/#137/#142 (Thanks, @andela-ysanni and @NikoRoberts!)
- Properly handle nested
script
tags. #127.
- Added :noopener HTML scrubber (Thanks, @tastycode!)
- 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!)
- The :unprintable scrubber now scrubs unprintable characters in CDATA nodes (like
<script>
). #124 - Allow negative values in CSS properties. Restores functionality that was reverted in v2.0.3. #91
- Fix error with
#to_text
when Loofah::Helpers hadn't been required. #75 - Allow multi-word data attributes. #84 (Thanks, @jstorimer!)
- Allow negative values in CSS properties. #85 (Thanks, @siddhartham!)
- Load RR correctly when running test files directly. (Thanks, @ktdreyer!)
- Extracted HTML5::Scrub#scrub_css_attribute to accommodate the Rails integration work. (Thanks, @kaspth!)
- ActionView helpers now must be required explicitly:
require "loofah/helpers"
- Support for Ruby 1.8.7 and prior has been dropped
- HTML5 whitelist allows the following ...
- tags:
article
,aside
,bdi
,bdo
,canvas
,command
,datalist
,details
,figcaption
,figure
,footer
,header
,mark
,meter
,nav
,output
,section
,summary
,time
- attributes:
data-*
(Thanks, Rafael Franca!) - URI attributes:
poster
andpreload
- tags:
- Addition of the
:unprintable
scrubber to remove unprintable characters from text nodes. #65 (Thanks, Matt Swanson!) Loofah.fragment
accepts an optional encoding argument, compatible withNokogiri::HTML::DocumentFragment.parse
. #62 (Thanks, Ben Atkins!)- HTML5 sanitizers now remove attributes without values. (Thanks, Kasper Timm Hansen!)
- HTML5 sanitizers' CSS keyword check now actually works (broken in v2.0). Additional regression tests added. (Thanks, Kasper Timm Hansen!)
- HTML5 sanitizers now allow negative arguments to CSS. #64 (Thanks, Jon Calhoun!)
- Declaring encoding in html5/scrub.rb. Without this, use of the ruby -KU option would cause havoc. (#32)
- Loofah::Helpers.sanitize_css is a replacement for Rails's built-in sanitize_css helper.
- Improving ActionView integration.
- Additional HTML5lib whitelist elements (from html5lib 1524:80b5efe26230). Up to date with HTML5lib ruby code as of 1723:7ee6a0331856.
- Whitelists (which are not part of the public API) are now Sets (were previously Arrays).
- Don't explode when encountering UTF-8 URIs. (#25, #29)
- Moved ActiveRecord functionality into
loofah-activerecord
gem. - Removed DEPRECATIONS.rdoc documenting 0.3.0 API changes.
- New methods Loofah::HTML::Document#to_text and Loofah::HTML::DocumentFragment#to_text do the right thing with whitespace. Note that these methods are significantly slower than #text. GH #12
- Loofah::Elements::BLOCK_LEVEL contains a canonical list of HTML4 block-level4 elements.
- Loofah::HTML::Document#text and Loofah::HTML::DocumentFragment#text will return unescaped HTML entities by passing :encode_special_chars => false.
- Loofah::HTML::Document#text and Loofah::HTML::DocumentFragment#text now escape HTML entities.
- Loofah::XssFoliate was not properly escaping HTML entities when implicitly scrubbing a string attribute. GH #17
- All built-in scrubbers are accepted by ActiveRecord::Base.xss_foliate
- Loofah::XssFoliate.xss_foliate_all_models replaces use of the constant LOOFAH_XSS_FOLIATE_ALL_MODELS
- Modified documentation for bootstrapping XssFoliate in a Rails app, since the use of Bundler breaks the previously-documented method. To be safe, always use an initializer file.
- Implemented Node#scrub! for scrubbing subtrees.
- Implemented NodeSet#scrub! for scrubbing a set of subtrees.
- Document.text now only serializes contents (ignores )
- , and added to the HTML5lib whitelist.
- Supporting Rails apps that aren't loading ActiveRecord. GH #10
- Mailing list is now [email protected] / http://librelist.com
- IRC channel is now #loofah on freenode.
- Manifest fixed. Whoops.
- Scrubber class introduced, allowing development of custom scrubbers.
- Added support for XML documents and fragments.
- Added :nofollow HTML scrubber (thanks Luke Melia!)
- Built-in scrubbing methods refactored to use Scrubber.
- Scrubbed Documents properly render html, head and body tags when serialized.
- New ActiveRecord extension
xss_foliate
, a drop-in replacement for xss_terminate[http://github.com/look/xss_terminate/tree/master]. - Replacement methods for Rails's helpers, Loofah::Rails.sanitize and Loofah::Rails.strip_tags.
- Official support (and test coverage) for Rails versions 2.3, 2.2, 2.1, 2.0 and 1.2.
- The methods strip_tags, whitewash, whitewash_document, sanitize, and sanitize_document have been deprecated. See DEPRECATED.rdoc for details on the equivalent calls with the post-0.2 API.
- ActiveRecord extension scrubs fields in a before_validation callback (was previously in a before_save)
- when loaded in a Rails app, automatically extend ActiveRecord::Base with html_fragment and html_document. GH #6 (Thanks Josh Nichols!)
- ActiveRecord scrubbing should generate strings instead of Document or DocumentFragment objects. GH #5
- init.rb fixed to support installation as a Rails plugin. GH #6 (Thanks Josh Nichols!)
- Swank new API.
- ActiveRecord extension.
- Uses Nokogiri's Document and DocumentFragment for parsing.
- Updated html5lib codes and tests to revision 1384:b9d3153d7be7.
- Deprecated the Dryopteris sanitization methods. Will be removed in 0.3.0.
- Documentation! Hey!
- Added whitewashing -- removal of all attributes and namespaced nodes. You know, for microsofty HTML.
- Birthday!