Skip to content

Commit

Permalink
Merge pull request #288 from lazyatom/add-min-height-and-max-height-t…
Browse files Browse the repository at this point in the history
…o-safelist

Allow CSS properties: min-height, max-height
  • Loading branch information
flavorjones authored Oct 25, 2024
2 parents 5ac17a8 + 6c70219 commit cc8a9f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/loofah/html5/safelist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,9 @@ module SafeList
"line-height",
"list-style",
"list-style-type",
"max-height",
"max-width",
"min-height",
"min-width",
"order",
"overflow",
Expand Down
14 changes: 14 additions & 0 deletions test/html5/test_sanitizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,27 @@ def test_css_function_sanitization_strips_style_attributes_with_unsafe_functions
assert_match(%r/<span><\/span>/, sane.inner_html)
end

def test_css_max_height
html = '<div style="max-height: 100%;"></div>'
sane = Nokogiri::HTML(Loofah.scrub_html4_fragment(html, :escape).to_xml)

assert_match(/max-height/, sane.inner_html)
end

def test_css_max_width
html = '<div style="max-width: 100%;"></div>'
sane = Nokogiri::HTML(Loofah.scrub_html4_fragment(html, :escape).to_xml)

assert_match(/max-width/, sane.inner_html)
end

def test_css_min_height
html = '<div style="min-height: 100%;"></div>'
sane = Nokogiri::HTML(Loofah.scrub_html4_fragment(html, :escape).to_xml)

assert_match(/min-height/, sane.inner_html)
end

def test_css_min_width
html = '<div style="min-width: 100%;"></div>'
sane = Nokogiri::HTML(Loofah.scrub_html4_fragment(html, :escape).to_xml)
Expand Down

0 comments on commit cc8a9f5

Please sign in to comment.