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

ruby-changes:28808

From: nobu <ko1@a...>
Date: Mon, 20 May 2013 22:42:53 +0900 (JST)
Subject: [ruby-changes:28808] nobu:r40860 (trunk): * lib/webrick/httpservlet/filehandler.rb (set_dir_list): set charset.

nobu	2013-05-20 22:41:16 +0900 (Mon, 20 May 2013)

  New Revision: 40860

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40860

  Log:
    * lib/webrick/httpservlet/filehandler.rb (set_dir_list): set charset.

  Modified files:
    trunk/lib/webrick/httpservlet/filehandler.rb

Index: lib/webrick/httpservlet/filehandler.rb
===================================================================
--- lib/webrick/httpservlet/filehandler.rb	(revision 40859)
+++ lib/webrick/httpservlet/filehandler.rb	(revision 40860)
@@ -437,7 +437,13 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/httpservlet/filehandler.rb#L437
           list.sort!{|a,b| b[idx] <=> a[idx] }
         end
 
-        res['content-type'] = "text/html"
+        type = "text/html"
+        case enc = Encoding.find('filesystem')
+        when Encoding::US_ASCII, Encoding::ASCII_8BIT
+        else
+          type << "; charset=\"#{enc.name}\""
+        end
+        res['content-type'] = type
 
         title = "Index of #{HTMLUtils::escape(req.path)}"
         res.body = <<-_end_of_html_

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

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