Project

General

Profile

Bug #8425 ยป webrick.patch

windwiny (wind winy), 05/19/2013 11:34 AM

View differences:

webrick/htmlutils.rb 2013-05-18 14:04:34 +0800
# Escapes &, ", > and < in +string+
def escape(string)
str = string ? string.dup : ""
str = string ? string.b.dup : "".b
str.gsub!(/&/n, '&amp;')
str.gsub!(/\"/n, '&quot;')
str.gsub!(/>/n, '&gt;')
str.gsub!(/</n, '&lt;')
str
str.force_encoding(Encoding.default_external)
end
module_function :escape
webrick/httpservlet/filehandler.rb 2013-05-18 14:04:21 +0800
dname = name
end
s = " <A HREF=\"#{HTTPUtils::escape(name)}\">#{HTMLUtils::escape(dname)}</A>"
s << " " * (30 - dname.bytesize)
s << " " * (30 - dname.bytesize) rescue nil
s << (time ? time.strftime("%Y/%m/%d %H:%M ") : " " * 22)
s << (size >= 0 ? size.to_s : "-") << "\n"
res.body << s
webrick/httputils.rb 2013-05-18 14:04:51 +0800
# Escapes HTTP reserved and unwise characters in +str+
def escape(str)
_escape(str, UNESCAPED)
_escape(str.b, UNESCAPED).force_encoding(Encoding.default_external)
end
##
# Unescapes HTTP reserved and unwise characters in +str+
def unescape(str)
_unescape(str, ESCAPED)
_unescape(str.b, ESCAPED).force_encoding(Encoding.default_external)
end
##
    (1-1/1)