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 committed Jul 13, 2016
1 parent 0978281 commit 41b8eb5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pages/app/presenters/refinery/pages/section_presenter.rb
Original file line number Diff line number Diff line change
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.include?(name) && !(name =~ /\Adata-[\w-]+\z/).present?
end

end
Expand Down

0 comments on commit 41b8eb5

Please sign in to comment.