Skip to content

Commit

Permalink
Merge pull request #190 from ahorek/page_break
Browse files Browse the repository at this point in the history
add page-break to safelist
  • Loading branch information
flavorjones authored Aug 26, 2020
2 parents 39e105c + a6d1d9e commit 490cd05
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 490cd05

Please sign in to comment.