Bug #3345: webrick test failure on Windows(?)
http://redmine.ruby-lang.org/issues/show/3345
e$B5/I<<Te(B: Usaku NAKAMURA
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$B%+%F%4%je(B: lib, Target version: 1.9.2
ruby -v: ruby 1.9.3dev (2010-05-26 trunk 28018) [i386-mswin32]
webricke$B$N%F%9%H$,0J2<$N$h$&$K<:GT$7$^$9!#e(B
- Failure:
test_cgi(TestWEBrickCGI) [C:/ruby-trunk/test/webrick/test_cgi.rb:40]:
webrick log start:
[2010-05-26 17:32:08] INFO WEBrick 1.3.1
[2010-05-26 17:32:08] INFO ruby 1.9.3 (2010-05-26) [i386-mswin32]
[2010-05-26 17:32:08] INFO WEBrick::HTTPServer#start: pid=6292
port=60199
[2010-05-26 17:32:08] WARN :RequestHandler is deprecated, please use
:RequestCallback
[2010-05-26 17:32:09] WARN :RequestHandler is deprecated, please use
:RequestCallback
[2010-05-26 17:32:11] WARN :RequestHandler is deprecated, please use
:RequestCallback
[2010-05-26 17:32:12] WARN :RequestHandler is deprecated, please use
:RequestCallback
[2010-05-26 17:32:12] ERROR Encoding::CompatibilityError: incompatible
character encodings: ASCII-8BIT and Windows-31J
C:/ruby-trunk/lib/webrick/httpservlet/filehandler.rb:225:in
expand_path' C:/ruby-trunk/lib/webrick/httpservlet/filehandler.rb:225:in
prevent_directory_traversal’
C:/ruby-trunk/lib/webrick/httpservlet/filehandler.rb:166:in
service' C:/ruby-trunk/lib/webrick/httpserver.rb:111:in
service’
C:/ruby-trunk/lib/webrick/httpserver.rb:70:in run' C:/ruby-trunk/lib/webrick/server.rb:183:in
block in
start_thread’
webrick log end.
<“/\xA4\xDB\xA4\xB2/\xA4\xDB\xA4\xB2”> expected but was
<"\n\n
Internal Server Error
\n incompatible character encodings: ASCII-8BIT and Windows-31J\n\n \n WEBrick/1.3.1 (Ruby/1.9.3/2010-05-26) OpenSSL/1.0.0 at\n 127.0.0.1:60199\n \n \n\n">.
e$B%/%i%$%"%s%H$+$iEO$5$l$?!Ve(B/%A4%DB%A4%B2/%A4%DB%A4%B2e$B!W$H$$$&e(B
e$B%Q%9$r<B%U%!%$%k%7%9%F%`$N%Q%9$KJQ49$7$h$&$H$7$F$$$k$o$1$G$9$,!"e(B
(1)
e$B!Ve(B/%A4%DB%A4%B2/%A4%DB%A4%B2e$B!W$re(Bunescapee$B$9$k$He(BASCII-8BITe$B$K$J$ke(B
(2) e$B$=$l$re(BFile.expand_pathe$B$KEO$9$H!“e(Bfilesystem
encodinge$B$G$”$k$O$:$Ne(B
cwde$B$H$/$C$D$1$h$&$H$9$k$N$G%(%i!<$K$J$ke(B
e$B$H$$$&OC$N$h$&$G$9!#e(B
e$B$H$$$&$o$1$G!"0J2<$N%Q%C%A$G$$$A$*$&D>$k$s$G$9$,!"OC$H$7$F$OB>$Ne(B
e$B%W%i%C%H%U%)!<%`$G$bH/@8$7$F$7$+$k$Y$-LdBj$N$h$&$J5$$,$9$k$N$K!"e(B
e$B$I$&$b;d$7$+F’$s$G$J$$$C$]$$$N$O$J$<$G$7$g$&e(B?
e$B$^$?!"D>$7J}$H$7$F$O$?$7$F$3$l$G$$$$$s$G$7$g$&$+e(B?
e$B$I$J$?$+65$($F$/$@$5$$!#e(B
Index: lib/webrick/httputils.rb
— lib/webrick/httputils.rb (revision 28018)
+++ lib/webrick/httputils.rb (working copy)
@@ -27,7 +27,7 @@ module WEBrick
while ret.sub!(%r’/(?!../)[^/]+/..(?:/|\Z)', ‘/’); end #
/foo/… => /foo
raise "abnormal path `#{path}'" if %r{/\.\.(/|\Z)} =~ ret
-
ret
-
endret.force_encoding(Encoding.find("filesystem"))
module_function :normalize_path