module Loofah::HtmlDocumentBehavior::ClassMethods
Public Instance Methods
Source
# File lib/loofah/concerns.rb, line 135 def parse(*args, &block) remove_comments_before_html_element(super) end
Calls superclass method
Private Instance Methods
Source
# File lib/loofah/concerns.rb, line 150 def remove_comments_before_html_element(doc) doc.children.each do |child| child.unlink if child.comment? end doc end
remove comments that exist outside of the HTML
element.
these comments are allowed by the HTML
spec:
https://www.w3.org/TR/html401/struct/global.html#h-7.1
but are not scrubbed by Loofah
because these nodes don’t meet the contract that scrubbers expect of a node (e.g., it can be replaced, sibling and children nodes can be created).