File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -108,8 +108,11 @@ def scrub_node(node)
108108 def scrub_attributes ( node )
109109 if @attributes
110110 node . attribute_nodes . each do |attr |
111- attr . remove if scrub_attribute? ( attr . name )
112- scrub_attribute ( node , attr )
111+ if scrub_attribute? ( attr . name )
112+ attr . remove
113+ else
114+ scrub_attribute ( node , attr )
115+ end
113116 end
114117
115118 scrub_css_attribute ( node )
Original file line number Diff line number Diff line change @@ -249,6 +249,16 @@ def scrub_attribute(node, attr)
249249 end
250250 end
251251
252+ def test_does_not_scrub_removed_attributes
253+ @scrubber = TestPermitScrubber . new
254+
255+ input = "<div class='foo' href='bar'></div>"
256+ frag = scrub_fragment ( input )
257+ assert_equal ( "<div class=\" foo\" ></div>" , frag )
258+
259+ assert_equal ( [ [ "div" , "class" ] ] , @scrubber . instance_variable_get ( :@scrub_attribute_args ) )
260+ end
261+
252262 def test_does_not_scrub_attributes_of_a_removed_node
253263 @scrubber = TestPermitScrubber . new
254264
You can’t perform that action at this time.
0 commit comments