diff --git a/lib/rails/html/sanitizer.rb b/lib/rails/html/sanitizer.rb index f9bef9f..a539102 100644 --- a/lib/rails/html/sanitizer.rb +++ b/lib/rails/html/sanitizer.rb @@ -40,15 +40,16 @@ def sanitize(html, options = {}) end # === Rails::Html::LinkSanitizer - # Removes a tags and href attributes leaving only the link text + # Removes +a+ tags and +href+ attributes leaving only the link text. # - # link_sanitizer = Rails::Html::LinkSanitizer.new - # link_sanitizer.sanitize('Only the link text will be kept.') - # # => Only the link text will be kept. + # link_sanitizer = Rails::Html::LinkSanitizer.new + # link_sanitizer.sanitize('Only the link text will be kept.') + # + # => 'Only the link text will be kept.' class LinkSanitizer < Sanitizer def initialize @link_scrubber = TargetScrubber.new - @link_scrubber.tags = %w(a href) + @link_scrubber.tags = %w(a) @link_scrubber.attributes = %w(href) end @@ -146,7 +147,7 @@ def allowed_tags(options) def allowed_attributes(options) options[:attributes] || self.class.allowed_attributes - end + end end WhiteListSanitizer = SafeListSanitizer diff --git a/test/sanitizer_test.rb b/test/sanitizer_test.rb index 6aa0509..8c579af 100644 --- a/test/sanitizer_test.rb +++ b/test/sanitizer_test.rb @@ -154,10 +154,6 @@ def test_strip_links_with_linkception assert_equal "Magic", link_sanitize("Magic") end - def test_strip_links_with_a_tag_in_href - assert_equal "FrrFox", link_sanitize("FrrFox") - end - def test_sanitize_form assert_sanitized "
", '' end