class Loofah::Scrubbers::Unprintable
the content is ever parsed by JavaScript - more information here:
U+2028 character right before the closing </p> tag. These characters can cause issues if
You may not be able to see the unprintable character in the above example, but there is a
=> “<p>Some text with an unprintable character at the end</p>”
Loofah.html5_fragment(markup).scrub!(:unprintable)
markup = “<p>Some text with an unprintable character at the endu2028</p>”:unprintable
removes unprintable Unicode characters.
=== scrub!(:unprintable)
def initialize # rubocop:disable Lint/MissingSuper
def initialize # rubocop:disable Lint/MissingSuper @direction = :top_down end
def scrub(node)
def scrub(node) if node.type == Nokogiri::XML::Node::TEXT_NODE || node.type == Nokogiri::XML::Node::CDATA_SECTION_NODE node.content = node.content.gsub(/\u2028|\u2029/, "") end CONTINUE end