File tree 2 files changed +7
-10
lines changed
2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -40,15 +40,16 @@ def sanitize(html, options = {})
40
40
end
41
41
42
42
# === Rails::Html::LinkSanitizer
43
- # Removes a tags and href attributes leaving only the link text
43
+ # Removes +a+ tags and + href+ attributes leaving only the link text.
44
44
#
45
- # link_sanitizer = Rails::Html::LinkSanitizer.new
46
- # link_sanitizer.sanitize('<a href="example.com">Only the link text will be kept.</a>')
47
- # # => Only the link text will be kept.
45
+ # link_sanitizer = Rails::Html::LinkSanitizer.new
46
+ # link_sanitizer.sanitize('<a href="example.com">Only the link text will be kept.</a>')
47
+ #
48
+ # => 'Only the link text will be kept.'
48
49
class LinkSanitizer < Sanitizer
49
50
def initialize
50
51
@link_scrubber = TargetScrubber . new
51
- @link_scrubber . tags = %w( a href )
52
+ @link_scrubber . tags = %w( a )
52
53
@link_scrubber . attributes = %w( href )
53
54
end
54
55
@@ -146,7 +147,7 @@ def allowed_tags(options)
146
147
147
148
def allowed_attributes ( options )
148
149
options [ :attributes ] || self . class . allowed_attributes
149
- end
150
+ end
150
151
end
151
152
152
153
WhiteListSanitizer = SafeListSanitizer
Original file line number Diff line number Diff line change @@ -154,10 +154,6 @@ def test_strip_links_with_linkception
154
154
assert_equal "Magic" , link_sanitize ( "<a href='http://www.rubyonrails.com/'>Mag<a href='http://www.ruby-lang.org/'>ic" )
155
155
end
156
156
157
- def test_strip_links_with_a_tag_in_href
158
- assert_equal "FrrFox" , link_sanitize ( "<href onlclick='steal()'>FrrFox</a></href>" )
159
- end
160
-
161
157
def test_sanitize_form
162
158
assert_sanitized "<form action=\" /foo/bar\" method=\" post\" ><input></form>" , ''
163
159
end
You can’t perform that action at this time.
0 commit comments