Class Loofah::Scrubbers::Escape
In: lib/loofah/scrubbers.rb
Parent: Scrubber
RuntimeError ScrubberNotFound Nokogiri::XML::DocumentFragment DocumentFragment Document Document Nokogiri::XML::Document DocumentFragment Nokogiri::HTML::DocumentFragment Nokogiri::HTML::Document Scrubber NoFollow Escape Strip Whitewash NewlineBlockElements Prune Scrubber WhiteListSanitizer FullSanitizer XML Scrub WhiteList HTML5 HTML DocumentDecorator MetaHelpers Elements NodeSet Node ScrubBehavior ClassMethods ActionView Helpers TextBehavior Scrubbers Loofah dot/f_0.png

scrub!(:escape)

+:escape+ performs HTML entity escaping on the unknown/unsafe tags:

   unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
   Loofah.fragment(unsafe_html).scrub!(:escape)
   => "ohai! <div>div is safe</div> &lt;foo&gt;but foo is &lt;b&gt;not&lt;/b&gt;&lt;/foo&gt;"

Methods

new   scrub  

Public Class methods

[Source]

# File lib/loofah/scrubbers.rb, line 114
      def initialize
        @direction = :top_down
      end

Public Instance methods

[Source]

# File lib/loofah/scrubbers.rb, line 118
      def scrub(node)
        return CONTINUE if html5lib_sanitize(node) == CONTINUE
        node.add_next_sibling Nokogiri::XML::Text.new(node.to_s, node.document)
        node.remove
        return STOP
      end

[Validate]