class StringTools::Sanitizer::IframeNormalizer

Public Class Methods

new(attributes) click to toggle source
# File lib/string_tools.rb, line 208
def initialize(attributes)
  @attributes = attributes
end

Public Instance Methods

call(env) click to toggle source
# File lib/string_tools.rb, line 212
def call(env)
  node = env[:node]

  return unless node.name == 'iframe'

  unless node[:src] =~ %r{^(http|https):?\/\/(www\.)?youtube?\.com\/}
    node.unlink
    return
  end

  Sanitize.node!(env[:node], elements: %w(iframe), attributes: {'iframe' => @attributes})
end