Project

General

Profile

Actions

Bug #8425

closed

webrick show local filesystem charset bug

Added by windwiny (wind winy) almost 11 years ago. Updated about 10 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
2.0.0
[ruby-core:55052]

Description

Shell command

ruby -run -e httpd Dir1

run a webrick http server, can not show no 8bit-ascii directory/file name.

this patch can fix this problem, can review it?

patch file

or github
https://github.com/windwiny/ruby/tree/webrick_fn


Files

webrick.patch (1.73 KB) webrick.patch windwiny (wind winy), 05/19/2013 11:34 AM
Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r40848.
wind, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


webrick: fix non-ascii escape bugs

  • lib/webrick/htmlutils.rb (WEBrick::HTMLUtils#escape): replace HTML
    meta chars even in non-ascii string. [Bug #8425] [ruby-core:55052]
  • lib/webrick/httputils.rb (WEBrick::HTTPUtils#{_escape,_unescape}):
    fix %-escape encodings. [Bug #8425] [ruby-core:55052]

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: REQUIRED

Updated by windwiny (wind winy) almost 11 years ago

@nobu (Nobuyoshi Nakada),

webrick\httputils.rb
def _unescape(str, regex)
str = str.b
str.gsub!(regex) {$1.hex.chr}
# encoding of %-unescaped string is unknown
str
end

_unescape return ASCII-8BIT str, may be improper?

can you test firefox on similar dir '/tmp/1/Uni1/2/Uni2/' ?

btw, webrick\httpservlet\filehandler.rb
list.each{ |name, time, size|
if name == ".."
dname = "Parent Directory"

  •      elsif name.bytesize > 25
    
  •        dname = name.sub(/^(.{23})(?:.*)/, '\1..')
         else
    
  •        dname = name
    
  •        dname = name[0...23] << '..'
         end
    

The delete line has a bug, The meaning all file has add '..', even filename short 25

Updated by usa (Usaku NAKAMURA) about 10 years ago

  • Backport changed from 1.9.3: REQUIRED, 2.0.0: REQUIRED to 1.9.3: DONE, 2.0.0: REQUIRED

backported into ruby_1_9_3 at r44934.

Updated by nagachika (Tomoyuki Chikanaga) about 10 years ago

  • Backport changed from 1.9.3: DONE, 2.0.0: REQUIRED to 1.9.3: DONE, 2.0.0: DONE

r40830 and r40848 were backported to ruby_2_0_0 at r45012.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0