Project

General

Profile

Bug #8425

webrick show local filesystem charset bug

Added by windwiny (wind winy) about 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
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

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

Associated revisions

Revision 88bcccd4
Added by nobu (Nobuyoshi Nakada) about 5 years 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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 40848
Added by nobu (Nobuyoshi Nakada) about 5 years 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]

Revision 40848
Added by nobu (Nobuyoshi Nakada) about 5 years 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]

Revision 40848
Added by nobu (Nobuyoshi Nakada) about 5 years 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]

Revision 40848
Added by nobu (Nobuyoshi Nakada) about 5 years 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]

Revision 40848
Added by nobu (Nobuyoshi Nakada) about 5 years 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]

Revision a20b957b
Added by usa (Usaku NAKAMURA) over 4 years ago

merge revision(s) 40848: [Backport #8425]

* 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] 

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@44934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 954b8281
Added by nagachika (Tomoyuki Chikanaga) over 4 years ago

merge revision(s) r40830,r40848: [Backport #8425]

* test/webrick/test_htmlutils.rb: add test for WEBrick::HTMLUtils.

* 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] 

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@45012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

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

#2 [ruby-core:55070] Updated by nobu (Nobuyoshi Nakada) about 5 years ago

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

#3 [ruby-core:55078] Updated by windwiny (wind winy) about 5 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

#4 [ruby-core:60698] Updated by usa (Usaku NAKAMURA) over 4 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.

#5 [ruby-core:60791] Updated by nagachika (Tomoyuki Chikanaga) over 4 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.

Also available in: Atom PDF