Skip to content

Commit 83cf440

Browse files
znzjeremyevans
authored andcommitted
Fix httpd error in CJK directory
[Bug #16753]
1 parent e58195f commit 83cf440

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/webrick/httpservlet/filehandler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def get_handler(req, res)
324324
end
325325

326326
def set_filename(req, res)
327-
res.filename = @root.dup
327+
res.filename = @root.b
328328
path_info = req.path_info.scan(%r|/[^/]*|)
329329

330330
path_info.unshift("") # dummy for checking @root dir

test/webrick/test_filehandler.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require_relative "utils.rb"
44
require "webrick"
55
require "stringio"
6+
require "tmpdir"
67

78
class WEBrick::TestFileHandler < Test::Unit::TestCase
89
def teardown
@@ -285,6 +286,18 @@ def test_short_filename
285286
end
286287
end
287288

289+
def test_cjk_in_path
290+
Dir.mktmpdir("\u3042") do |dir|
291+
File.write("#{dir}/\u3042.txt", "test_cjk_in_path")
292+
config = { :DocumentRoot => dir }
293+
TestWEBrick.start_httpserver(config) do |server, addr, port, log|
294+
http = Net::HTTP.new(addr, port)
295+
req = Net::HTTP::Get.new("/%E3%81%82.txt")
296+
http.request(req){|res| assert_equal("200", res.code, log.call) }
297+
end
298+
end
299+
end
300+
288301
def test_script_disclosure
289302
return if File.executable?(__FILE__) # skip on strange file system
290303

0 commit comments

Comments
 (0)