[前][次][番号順一覧][スレッド一覧]

ruby-changes:61671

From: Kazuhiro <ko1@a...>
Date: Thu, 11 Jun 2020 13:42:20 +0900 (JST)
Subject: [ruby-changes:61671] e698bf1a7f (master): [ruby/webrick] Fix httpd error in CJK directory

https://git.ruby-lang.org/ruby.git/commit/?id=e698bf1a7f

From e698bf1a7f06452c9509f33e865cc9797dde15b9 Mon Sep 17 00:00:00 2001
From: Kazuhiro NISHIYAMA <zn@m...>
Date: Fri, 3 Apr 2020 17:29:12 +0900
Subject: [ruby/webrick] Fix httpd error in CJK directory

[Bug #16753]

https://github.com/ruby/webrick/commit/83cf440858

diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb
index 7cac05d..0780faf 100644
--- a/lib/webrick/httpservlet/filehandler.rb
+++ b/lib/webrick/httpservlet/filehandler.rb
@@ -324,7 +324,7 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/httpservlet/filehandler.rb#L324
       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 ef56762..821d91b 100644
--- a/test/webrick/test_filehandler.rb
+++ b/test/webrick/test_filehandler.rb
@@ -3,6 +3,7 @@ require "test/unit" https://github.com/ruby/ruby/blob/trunk/test/webrick/test_filehandler.rb#L3
 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 https://github.com/ruby/ruby/blob/trunk/test/webrick/test_filehandler.rb#L288
     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
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]