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
15 15
    # Escapes &, ", > and < in +string+
16 16

  
17 17
    def escape(string)
18
      str = string ? string.dup : ""
18
      str = string ? string.b.dup : "".b
19 19
      str.gsub!(/&/n, '&amp;')
20 20
      str.gsub!(/\"/n, '&quot;')
21 21
      str.gsub!(/>/n, '&gt;')
22 22
      str.gsub!(/</n, '&lt;')
23
      str
23
      str.force_encoding(Encoding.default_external)
24 24
    end
25 25
    module_function :escape
26 26

  
webrick/httpservlet/filehandler.rb 2013-05-18 14:04:21 +0800
463 463
            dname = name
464 464
          end
465 465
          s =  " <A HREF=\"#{HTTPUtils::escape(name)}\">#{HTMLUtils::escape(dname)}</A>"
466
          s << " " * (30 - dname.bytesize)
466
          s << " " * (30 - dname.bytesize) rescue nil
467 467
          s << (time ? time.strftime("%Y/%m/%d %H:%M      ") : " " * 22)
468 468
          s << (size >= 0 ? size.to_s : "-") << "\n"
469 469
          res.body << s
webrick/httputils.rb 2013-05-18 14:04:51 +0800
452 452
    # Escapes HTTP reserved and unwise characters in +str+
453 453

  
454 454
    def escape(str)
455
      _escape(str, UNESCAPED)
455
      _escape(str.b, UNESCAPED).force_encoding(Encoding.default_external)
456 456
    end
457 457

  
458 458
    ##
459 459
    # Unescapes HTTP reserved and unwise characters in +str+
460 460

  
461 461
    def unescape(str)
462
      _unescape(str, ESCAPED)
462
      _unescape(str.b, ESCAPED).force_encoding(Encoding.default_external)
463 463
    end
464 464

  
465 465
    ##