diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2020-06-18 23:42:02 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2020-06-18 23:43:48 +0900 |
commit | 750203c514e0e9a49f7d53fb54084e6844fca42a (patch) | |
tree | c7dc834d56995aa4283b7753302a569751c8110d /lib | |
parent | 50c13eb718d961c333ac832e734dae21ca7a8330 (diff) |
lib/webrick/httpservlet/filehandler.rb: always handle a path as UTF-8
https://rubyci.org/logs/mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-master/log/20200618T113134Z.fail.html.gz
```
1) Failure:
WEBrick::TestFileHandler#test_cjk_in_path [D:/tmp/mswin-build20200618-84004-1t0dh8f/ruby/test/webrick/utils.rb:72]:
exceptions on 2 threads:
webrick log start:
[2020-06-18 22:18:07] ERROR `/??.txt' not found.
webrick log end
Filesystem encoding is Windows-31J.
<"200"> expected but was
<"404">.
```
Diffstat (limited to 'lib')
-rw-r--r-- | lib/webrick/httpservlet/filehandler.rb | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb index 2044d6eabe..5bd96317e6 100644 --- a/lib/webrick/httpservlet/filehandler.rb +++ b/lib/webrick/httpservlet/filehandler.rb @@ -36,17 +36,12 @@ module WEBrick def initialize(server, local_path) super(server, local_path) - @local_path = local_path + @local_path = local_path.dup.force_encoding("UTF-8") end # :stopdoc: def do_GET(req, res) - case enc = Encoding.find('filesystem') - when Encoding::US_ASCII, Encoding::ASCII_8BIT - else - @local_path = @local_path.dup.force_encoding(enc) - end st = File::stat(@local_path) mtime = st.mtime res['etag'] = sprintf("%x-%x-%x", st.ino, st.size, st.mtime.to_i) |