Skip to content

Commit

Permalink
Refactor CustomScrubber to fix support of data-attr
Browse files Browse the repository at this point in the history
  • Loading branch information
Brice Sanchez authored and parndt committed Jul 14, 2016
1 parent 4212674 commit 3d5d1a6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pages/app/presenters/refinery/pages/section_presenter.rb
Expand Up @@ -91,13 +91,16 @@ def initialize(tags, attributes)
@attributes = attributes
end

#see https://github.com/flavorjones/loofah/blob/master/lib/loofah/html5/scrub.rb#L21
def scrub_attributes(node)
node.attribute_nodes.each do |attr_node|
next if attr_node.node_name =~ /\Adata-[\w-]+\z/
def allowed_node?(node)
tags.include?(node.name)
end

super
end
def skip_node?(node)
node.text?
end

def scrub_attribute?(name)
attributes.exclude?(name) && name !~ /\Adata-[\w-]+\z/
end

end
Expand Down

0 comments on commit 3d5d1a6

Please sign in to comment.