Bug #8425

webrick show local filesystem charset bug

Added by wind winy 11 months ago. Updated 2 months ago.

[ruby-core:55052]
Status:Closed
Priority:Normal
Assignee:-
Category:lib
Target version:-
ruby -v:2.0.0 Backport:1.9.3: DONE, 2.0.0: DONE

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

webrick.patch Magnifier (1.73 KB) wind winy, 05/19/2013 11:34 AM

Associated revisions

Revision 40848
Added by Nobuyoshi Nakada 11 months ago

webrick: fix non-ascii escape bugs

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

History

#1 Updated by Nobuyoshi Nakada 11 months 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]
  • lib/webrick/httputils.rb (WEBrick::HTTPUtils#{escape,unescape}): fix %-escape encodings. [Bug #8425]

#2 Updated by Nobuyoshi Nakada 11 months ago

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

#3 Updated by wind winy 11 months ago

@nobu,

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

#4 Updated by Usaku NAKAMURA 2 months ago

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

backported into ruby19_3 at r44934.

#5 Updated by Tomoyuki Chikanaga 2 months 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 ruby20_0 at r45012.

Also available in: Atom PDF