[#41531] [Bug #3385] ext/dbm: accept various version of db — Takahiro Kambe <redmine@...>

Bug #3385: ext/dbm: accept various version of db

10 messages 2010/06/03

[#41600] 質問・提案:cgi.rbの後継となるライブラリについて — Dice <tetradice@...>

Diceです。cgi.rbの後継ライブラリについて質問させてください。

16 messages 2010/06/13
[#41606] Re: 質問・提案:cgi.rbの後継となるライブラリについて — Fujioka <fuj@...> 2010/06/14

藤岡です。

[#41607] Re: 質問・提案:cgi.rbの後継となるライブラリについて — KAKUTANI Shintaro <shintaro.kakutani@...> 2010/06/14

かくたにです。

[#41616] Re: 質問・提案:cgi.rbの後継となるライブラリについて — Dice <tetradice@...> 2010/06/15

藤岡さん、かくたにさん、返信ありがとうございます。

[#41617] Re: 質問・提案:cgi.rbの後継となるライブラリについて — Fujioka <fuj@...> 2010/06/16

藤岡です。

[#41656] Re: 質問・提案:cgi.rbの後継となるライブラリについて — Dice <tetradice@...> 2010/06/20

Diceです。藤岡さん、返信ありがとうございます。

[#41623] [Feature:trunk] argument delegation — Nobuyoshi Nakada <nobu@...>

なかだです。

23 messages 2010/06/16
[#41625] Re: [Feature:trunk] argument delegation — Yusuke ENDOH <mame@...> 2010/06/16

遠藤です。

[#41627] Re: [Feature:trunk] argument delegation — Yukihiro Matsumoto <matz@...> 2010/06/16

まつもと ゆきひろです

[#41702] WIN32OLE_METHOD offset_vtbl — kuwamoto shintaro <beuniv@...>

こんばんわ

16 messages 2010/06/23
[#41712] Re: WIN32OLE_METHOD offset_vtbl — Masaki Suketa <masaki.suketa@...> 2010/06/24

助田です。

[ruby-dev:41615] [Bug #3345] webrick test failure on Windows(?)

From: Yusuke Endoh <redmine@...>
Date: 2010-06-15 18:13:55 UTC
List: ruby-dev #41615
チケット #3345 が更新されました。 (by Yusuke Endoh)

担当者 Usaku NAKAMURAにセット

遠藤です。

> というわけで、以下のパッチでいちおう直るんですが、話としては他の
> プラットフォームでも発生してしかるべき問題のような気がするのに、
> どうも私しか踏んでないっぽいのはなぜでしょう?


File.expand_path("/webrick.cgi/\xA4\xDB\xA4\xB2/\xA4\xDB\xA4\xB2".force_encoding("ASCII-8BIT"))

のようなことが実行されていて、先頭が / で始まっているため、Linux など
だと特に何もしないけれど、Windows だと何か (ドライブレター?) を足そう
とするため落ちるのかと思います。

unak さんのパッチだと、Linux でエラーが発生するようになりました。
filesystem encoding は UTF-8 ですが、このパスは UTF-8 として invalid
なので、=~ で正規表現マッチができないことが原因です。


  1) Failure:
test_cgi(TestWEBrickCGI) [/home/mame/work/ruby/test/webrick/test_cgi.rb:40]:
webrick log start:
  [2010-06-16 02:48:55] INFO  WEBrick 1.3.1
  [2010-06-16 02:48:55] INFO  ruby 1.9.3 (2010-06-16) [i686-linux]
  [2010-06-16 02:48:55] INFO  WEBrick::HTTPServer#start: pid=15315 port=38912
  [2010-06-16 02:48:55] WARN  :RequestHandler is deprecated, please use :RequestCallback

  [2010-06-16 02:48:55] WARN  :RequestHandler is deprecated, please use :RequestCallback

  [2010-06-16 02:48:55] WARN  :RequestHandler is deprecated, please use :RequestCallback

  [2010-06-16 02:48:55] WARN  :RequestHandler is deprecated, please use :RequestCallback
  [2010-06-16 02:48:55] ERROR ArgumentError: invalid byte sequence in UTF-8
        /home/mame/work/ruby/lib/webrick/httpserver.rb:196:in `=~'
        /home/mame/work/ruby/lib/webrick/httpserver.rb:196:in `scan'
        /home/mame/work/ruby/lib/webrick/httpserver.rb:136:in `search_servlet'
        /home/mame/work/ruby/lib/webrick/httpserver.rb:105:in `service'
        /home/mame/work/ruby/lib/webrick/httpserver.rb:70:in `run'
        /home/mame/work/ruby/lib/webrick/server.rb:183:in `block in start_thread'


prevent_directory_traversal の問題を正確に理解していないのですが、
問題がおきるのが Windows だけで、\\ の扱いだけの問題だとしたら、
File.expand_path を使わず gsub で処理するといいのではないでしょう
か。


diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb
index 32c1965..50bf27c 100644
--- a/lib/webrick/httpservlet/filehandler.rb
+++ b/lib/webrick/httpservlet/filehandler.rb
@@ -214,17 +214,13 @@ module WEBrick
         # character in URI notation. So the value of path_info should be
         # normalize before accessing to the filesystem.
 
-        if trailing_pathsep?(req.path_info)
-          # File.expand_path removes the trailing path separator.
-          # Adding a character is a workaround to save it.
-          #  File.expand_path("/aaa/")        #=> "/aaa"
-          #  File.expand_path("/aaa/" + "x")  #=> "/aaa/x"
-          expanded = File.expand_path(req.path_info + "x")
-          expanded.chop!  # remove trailing "x"
-        else
-          expanded = File.expand_path(req.path_info)
+        is_windows = RUBY_PLATFORM =~ /mswin/  ||
+                     RUBY_PLATFORM =~ /mingw/  ||
+                     RUBY_PLATFORM =~ /bccwin/ ||
+                     RUBY_PLATFORM =~ /wince/
+        if is_windows
+          req.path_info = req.path_info.gsub("\\", "/")
         end
-        req.path_info = expanded
       end
 
       def exec_handler(req, res)

-- 
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3345

----------------------------------------
http://redmine.ruby-lang.org

In This Thread