In Files

  • webrick/htmlutils.rb

Methods

Class/Module Index [+]

Quicksearch

WEBrick::HTMLUtils

Public Class Methods

escape(string) click to toggle source

Escapes &, “, > and < in string

 
               # File webrick/htmlutils.rb, line 17
def escape(string)
  return "" unless string
  str = string.dup.force_encoding('binary')
  str.gsub!(/&/, '&amp;')
  str.gsub!(/\"/, '&quot;')
  str.gsub!(/>/, '&gt;')
  str.gsub!(/</, '&lt;')
  str.force_encoding(string.encoding)
end