Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow HTML5 element wbr #213

Merged
merged 2 commits into from Jul 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,18 @@
# Changelog

## next / unreleased

### Features

* Allow HTML5 element `wbr`.


### Changes

* 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.


## 2.10.0 / 2021-06-06

### Features
Expand Down
9 changes: 3 additions & 6 deletions lib/loofah/html5/safelist.rb
Expand Up @@ -140,6 +140,7 @@ module SafeList
"ul",
"var",
"video",
"wbr",
])

MATHML_ELEMENTS = Set.new([
Expand Down Expand Up @@ -788,18 +789,14 @@ module SafeList
ALLOWED_PROTOCOLS = ACCEPTABLE_PROTOCOLS
ALLOWED_URI_DATA_MEDIATYPES = ACCEPTABLE_URI_DATA_MEDIATYPES

# TODO: remove VOID_ELEMENTS in a future major release
# and put it in the tests (it is used only for testing, not for functional behavior)
VOID_ELEMENTS = Set.new([
"area",
"base",
"br",
"col",
"embed",
"hr",
"img",
"input",
"link",
"meta",
"param",
])

# additional tags we should consider safe since we have libxml2 fixing up our documents.
Expand Down
6 changes: 6 additions & 0 deletions test/html5/test_sanitizer.rb
Expand Up @@ -68,6 +68,12 @@ def assert_completes_in_reasonable_time(&block)
end
end

HTML5::SafeList::VOID_ELEMENTS.each do |tag_name|
define_method "test_void_#{tag_name}_is_in_allowed_list" do
assert_includes(HTML5::SafeList::ALLOWED_ELEMENTS, tag_name)
end
end

##
## libxml2 downcases elements, so this is moot.
##
Expand Down