diff options
author | Timm <kaspth@gmail.com> | 2013-07-02 21:54:34 +0200 |
---|---|---|
committer | Timm <kaspth@gmail.com> | 2014-06-15 23:35:24 +0200 |
commit | 3e4ae8e5a21e1460bf0674211aef8d539c065701 (patch) | |
tree | 742d8bbeaf3f3198cdb182393b5354b4749945b4 /actionview | |
parent | 2622da17585a58fc75d3f9b5fc80eb03930fa156 (diff) | |
download | rails-3e4ae8e5a21e1460bf0674211aef8d539c065701.tar.gz rails-3e4ae8e5a21e1460bf0674211aef8d539c065701.tar.bz2 rails-3e4ae8e5a21e1460bf0674211aef8d539c065701.zip |
Reordered form removal with stripping.
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb | 11 | ||||
-rw-r--r-- | actionview/test/template/sanitize_helper_test.rb | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb b/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb index cbddf3481c..f70b47f32a 100644 --- a/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb +++ b/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb @@ -14,9 +14,12 @@ module ActionView class LinkSanitizer def initialize @link_scrubber = Loofah::Scrubber.new do |node| - next unless node.name == 'a' - node.before node.children - node.remove + if node.name == 'a' + node.before node.children + node.remove + else + Loofah::HTML5::Scrub.scrub_attributes(node) + end end end @@ -40,8 +43,8 @@ module ActionView @permit_scrubber.attributes = options[:attributes] loofah_fragment.scrub!(@permit_scrubber) else - loofah_fragment.scrub!(:strip) loofah_fragment.xpath("./form").each { |form| form.remove } + loofah_fragment.scrub!(:strip) end loofah_fragment.to_s end diff --git a/actionview/test/template/sanitize_helper_test.rb b/actionview/test/template/sanitize_helper_test.rb index f7c8f36b78..ab7157eec5 100644 --- a/actionview/test/template/sanitize_helper_test.rb +++ b/actionview/test/template/sanitize_helper_test.rb @@ -22,7 +22,7 @@ class SanitizeHelperTest < ActionView::TestCase def test_should_sanitize_illegal_style_properties raw = %(display:block; position:absolute; left:0; top:0; width:100%; height:100%; z-index:1; background-color:black; background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg); background-x:center; background-y:center; background-repeat:repeat;) - expected = %(display: block; width: 100%; height: 100%; background-color: black; background-image: ; background-x: center; background-y: center;) + expected = %(display: block; width: 100%; height: 100%; background-color: black; background-x: center; background-y: center;) assert_equal expected, sanitize_css(raw) end |