Class: Loofah::Scrubbers::Strip

Inherits:
Loofah::Scrubber show all
Defined in:
lib/loofah/scrubbers.rb

Overview

scrub!(:strip)

+:strip+ removes unknown/unsafe tags, but leaves behind the pristine contents:

   unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
   Loofah.fragment(unsafe_html).scrub!(:strip)
   => "ohai! <div>div is safe</div> but foo is <b>not</b>"

Constant Summary

Constant Summary

Constants inherited from Loofah::Scrubber

Loofah::Scrubber::CONTINUE, Loofah::Scrubber::STOP

Instance Attribute Summary

Attributes inherited from Loofah::Scrubber

#block, #direction

Instance Method Summary (collapse)

Methods inherited from Loofah::Scrubber

#traverse

Constructor Details

- (Strip) initialize

A new instance of Strip



72
73
74
# File 'lib/loofah/scrubbers.rb', line 72

def initialize
  @direction = :bottom_up
end

Instance Method Details

- (Object) scrub(node)



76
77
78
79
80
# File 'lib/loofah/scrubbers.rb', line 76

def scrub(node)
  return CONTINUE if html5lib_sanitize(node) == CONTINUE
  node.before node.children
  node.remove
end