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

Whitelist summary and details element. #171

Merged
merged 1 commit into from
Jan 21, 2015
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/html/pipeline/sanitization_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SanitizationFilter < Filter
:elements => %w(
h1 h2 h3 h4 h5 h6 h7 h8 br b i strong em a pre code img tt
div ins del sup sub p ol ul table thead tbody tfoot blockquote
dl dt dd kbd q samp var hr ruby rt rp li tr td th s strike
dl dt dd kbd q samp var hr ruby rt rp li tr td th s strike summary details
),
:remove_contents => ['script'],
:attributes => {
Expand All @@ -57,13 +57,13 @@ class SanitizationFilter < Filter
'border', 'cellpadding', 'cellspacing', 'char',
'charoff', 'charset', 'checked', 'cite',
'clear', 'cols', 'colspan', 'color',
'compact', 'coords', 'datetime', 'details', 'dir',
'compact', 'coords', 'datetime', 'dir',
'disabled', 'enctype', 'for', 'frame',
'headers', 'height', 'hreflang',
'hspace', 'ismap', 'label', 'lang',
'longdesc', 'maxlength', 'media', 'method',
'multiple', 'name', 'nohref', 'noshade',
'nowrap', 'prompt', 'readonly', 'rel', 'rev',
'nowrap', 'open', 'prompt', 'readonly', 'rel', 'rev',
'rows', 'rowspan', 'rules', 'scope',
'selected', 'shape', 'size', 'span',
'start', 'summary', 'tabindex', 'target',
Expand Down
24 changes: 24 additions & 0 deletions test/html/pipeline/sanitization_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,28 @@ def test_table_sections_are_not_removed
</table>)
assert_equal orig, SanitizationFilter.call(orig).to_s
end

def test_summary_tag_are_not_removed
orig = %(<summary>Foo</summary>)
assert_equal orig, SanitizationFilter.call(orig).to_s
end

def test_details_tag_and_open_attribute_are_not_removed
orig = %(<details open>Foo</details>)
assert_equal orig, SanitizationFilter.call(orig).to_s
end

def test_nested_details_tag_are_not_removed
orig = <<-NESTED
<details>
<summary>Foo</summary>
<details>
Bar
<summary>Baz</summary>
</details>
Qux
</details>
NESTED
assert_equal orig, SanitizationFilter.call(orig).to_s
end
end