Support for the Ruby 2.1 series ended on March 31 2017. See here for details.

In Files

  • webrick/htmlutils.rb
  • webrick/httpservlet/filehandler.rb

Methods

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.b
  str.gsub!(/&/n, '&amp;')
  str.gsub!(/\"/n, '&quot;')
  str.gsub!(/>/n, '&gt;')
  str.gsub!(/</n, '&lt;')
  str.force_encoding(string.encoding)
end