Skip to content

Commit

Permalink
Fix httpd error in CJK directory
Browse files Browse the repository at this point in the history
[Bug #16753]
  • Loading branch information
znz authored and jeremyevans committed May 26, 2020
1 parent e58195f commit 83cf440
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/webrick/httpservlet/filehandler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def get_handler(req, res)
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
Expand Down
13 changes: 13 additions & 0 deletions test/webrick/test_filehandler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require_relative "utils.rb"
require "webrick"
require "stringio"
require "tmpdir"

class WEBrick::TestFileHandler < Test::Unit::TestCase
def teardown
Expand Down Expand Up @@ -285,6 +286,18 @@ def test_short_filename
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

Expand Down

0 comments on commit 83cf440

Please sign in to comment.