123456789_123456789_123456789_123456789_123456789_

Module: WEBrick::HTMLUtils

Relationships & Source Files
Defined in: lib/webrick/htmlutils.rb

Class Method Summary

Class Method Details

.escape(string) (mod_func)

Escapes &, “, > and < in string

[ GitHub ]

  
# File 'lib/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