diff options
author | Kazuhiro NISHIYAMA <zn@mbf.nifty.com> | 2020-04-03 17:29:12 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-06-11 13:38:32 +0900 |
commit | e698bf1a7f06452c9509f33e865cc9797dde15b9 (patch) | |
tree | ff9285a370c387823ba37f048c9ef232d11b456c | |
parent | 6742fcf5531f29b1cce33ab32895513b87f3f53e (diff) | |
download | ruby-e698bf1a7f06452c9509f33e865cc9797dde15b9.tar.gz |
[ruby/webrick] Fix httpd error in CJK directory
[Bug #16753]
https://github.com/ruby/webrick/commit/83cf440858
-rw-r--r-- | lib/webrick/httpservlet/filehandler.rb | 2 | ||||
-rw-r--r-- | test/webrick/test_filehandler.rb | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb index 7cac05d818..0780faf202 100644 --- a/lib/webrick/httpservlet/filehandler.rb +++ b/lib/webrick/httpservlet/filehandler.rb @@ -324,7 +324,7 @@ module WEBrick end def set_filename(req, res) - res.filename = @root.dup + res.filename = @root.b path_info = req.path_info.scan(%r|/[^/]*|) path_info.unshift("") # dummy for checking @root dir diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb index ef56762abe..821d91b3cd 100644 --- a/test/webrick/test_filehandler.rb +++ b/test/webrick/test_filehandler.rb @@ -3,6 +3,7 @@ require "test/unit" require_relative "utils.rb" require "webrick" require "stringio" +require "tmpdir" class WEBrick::TestFileHandler < Test::Unit::TestCase def teardown @@ -287,6 +288,18 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase end end + def test_cjk_in_path + Dir.mktmpdir("\u3042") do |dir| + File.write("#{dir}/\u3042.txt", "test_cjk_in_path") + config = { :DocumentRoot => dir } + TestWEBrick.start_httpserver(config) do |server, addr, port, log| + http = Net::HTTP.new(addr, port) + req = Net::HTTP::Get.new("/%E3%81%82.txt") + http.request(req){|res| assert_equal("200", res.code, log.call) } + end + end + end + def test_script_disclosure return if File.executable?(__FILE__) # skip on strange file system |