Class: UniversalRenderer::SSR::Scrubber

Inherits:
Loofah::Scrubber
  • Object
show all
Defined in:
lib/universal_renderer/ssr/scrubber.rb

Instance Method Summary collapse

Constructor Details

#initializeScrubber

Returns a new instance of Scrubber.



6
7
8
9
# File 'lib/universal_renderer/ssr/scrubber.rb', line 6

def initialize
  super
  @direction = :top_down
end

Instance Method Details

#scrub(node) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/universal_renderer/ssr/scrubber.rb', line 11

def scrub(node)
  # Primary actions: stop if script, continue if a passthrough tag, otherwise clean attributes.
  return Loofah::Scrubber::STOP if handle_script_node(node) # Checks for <script> and removes it

  # Allows <link rel="stylesheet">, <style>, <meta> to pass through this scrubber.
  return Loofah::Scrubber::CONTINUE if passthrough_node?(node)

  # For all other nodes, clean potentially harmful attributes.
  clean_attributes(node)
  # Default Loofah behavior (CONTINUE for children) applies if not returned earlier.
end