File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -146,9 +146,11 @@ def scrub_attribute(node, attr_node)
146
146
attr_node . remove
147
147
end
148
148
end
149
+
149
150
if Loofah ::HTML5 ::SafeList ::SVG_ATTR_VAL_ALLOWS_REF . include? ( attr_name )
150
- attr_node . value = attr_node . value . gsub ( /url \s * \( \s *[^# \s ][^)]+? \) /m , ' ' ) if attr_node . value
151
+ Loofah :: HTML5 :: Scrub . scrub_attribute_that_allows_local_ref ( attr_node )
151
152
end
153
+
152
154
if Loofah ::HTML5 ::SafeList ::SVG_ALLOW_LOCAL_HREF . include? ( node . name ) && attr_name == 'xlink:href' && attr_node . value =~ /^\s *[^#\s ].*/m
153
155
attr_node . remove
154
156
end
Original file line number Diff line number Diff line change @@ -606,6 +606,16 @@ def test_disallow_the_dangerous_safelist_combination_of_select_and_style
606
606
refute_includes ( sanitized , "style" )
607
607
end
608
608
609
+ def test_scrubbing_svg_attr_values_that_allow_ref
610
+ input = %Q(<div fill="yellow url(http://bad.com/) #fff">hey</div>)
611
+ expected = %Q(<div fill="yellow #fff">hey</div>)
612
+ actual = scope_allowed_attributes %w( fill ) do
613
+ safe_list_sanitize ( input )
614
+ end
615
+
616
+ assert_equal ( expected , actual )
617
+ end
618
+
609
619
protected
610
620
611
621
def xpath_sanitize ( input , options = { } )
You can’t perform that action at this time.
0 commit comments