Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#_esc_html(s) ⇒ Object

$Rev: 1 $ $Release: 0.1.0 $ copyright© 2007 kuwata-lab.com all rights reserved. License: public domain



8
9
10
# File 'lib/cgi_exception.rb', line 8

def _esc_html(s)
  s.to_s.gsub(/&/,'&amp;').gsub(/</,'&lt;').gsub(/>/,'&gt;').gsub(/"/,'&quot;')
end

#_print_stack_trace(ex, out = $stderr, header = "Content-Type: text/html\r\n") ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/cgi_exception.rb', line 12

def _print_stack_trace(ex, out=$stderr, header="Content-Type: text/html\r\n")
  out ||= $stderr
  out << header << "\r\n" if header
  arr = ex.backtrace
  out << "<pre style=\"color:#CC0000\">"
  out << "<b>#{_esc_html arr[0]}: #{_esc_html ex.message} (#{ex.class.name})</b>\n"
  arr[1..-1].each {|s| out << "        from #{_esc_html s}\n" }
  out << "</pre>"
end