Module: Vidibus::Xss::Extensions::String

Defined in:
lib/vidibus/xss/extensions/string.rb

Instance Method Summary collapse

Instance Method Details

#escape_xssObject

Prepares XSS content for rendering.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vidibus/xss/extensions/string.rb', line 7

def escape_xss
  regexp = {
    /^\/\/.+$/ => '', # remove comments
    # /\n\s*/ => '', # trim indentation and remove linebreaks
    /\/\/\<!\[CDATA\[(.*?)\/\/\]\]\>/ => "\\1" # remove //<![CDATA[...content...//]]>
  }
  c = clone
  for s, r in regexp
    c.gsub!(s,r)
  end
  c
end