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

add page-break to safelist #190

Merged
merged 2 commits into from Aug 26, 2020
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,11 @@

## unreleased

### Features

* Allow CSS properties `page-break-before`, `page-break-inside`, and `page-break-after`. [[#190](https://github.com/flavorjones/loofah/issues/190)] (Thanks, [@ahorek](https://github.com/ahorek)!)


### Fixes

* Don't drop the `!important` rule from some CSS properties. [[#191](https://github.com/flavorjones/loofah/issues/191)] (Thanks, [@b7kich](https://github.com/b7kich)!)
Expand Down
3 changes: 3 additions & 0 deletions lib/loofah/html5/safelist.rb
Expand Up @@ -576,6 +576,9 @@ module SafeList
"list-style-type",
"max-width",
"overflow",
"page-break-after",
"page-break-before",
"page-break-inside",
"pause",
"pause-after",
"pause-before",
Expand Down
19 changes: 19 additions & 0 deletions test/html5/test_sanitizer.rb
Expand Up @@ -379,6 +379,25 @@ def test_css_max_width
assert_match %r/max-width/, sane.inner_html
end

def test_css_page_break_after
html = '<div style="page-break-after:always;"></div>'
sane = Nokogiri::HTML(Loofah.scrub_fragment(html, :escape).to_xml)
assert_match %r/page-break-after:always/, sane.inner_html
end

def test_css_page_break_before
html = '<div style="page-break-before:always;"></div>'
sane = Nokogiri::HTML(Loofah.scrub_fragment(html, :escape).to_xml)
assert_match %r/page-break-before:always/, sane.inner_html
end

def test_css_page_break_inside
html = '<div style="page-break-inside:auto;"></div>'
sane = Nokogiri::HTML(Loofah.scrub_fragment(html, :escape).to_xml)
assert_match %r/page-break-inside:auto/, sane.inner_html
end


def test_issue_90_slow_regex
skip("timing tests are hard to make pass and have little regression-testing value")

Expand Down