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

ruby-changes:43658

From: normal <ko1@a...>
Date: Sat, 23 Jul 2016 01:43:18 +0900 (JST)
Subject: [ruby-changes:43658] normal:r55731 (trunk): webrick: filter out HTTP_PROXY for CGIHandler

normal	2016-07-23 01:43:12 +0900 (Sat, 23 Jul 2016)

  New Revision: 55731

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55731

  Log:
    webrick: filter out HTTP_PROXY for CGIHandler
    
    * lib/webrick/httpservlet/cgihandler.rb (do_GET): delete HTTP_PROXY
    * test/webrick/test_cgi.rb (test_cgi_env): new test
    * test/webrick/webrick.cgi (do_GET): new endpoint to dump env
      [ruby-core:76511] [Bug #12610]

  Modified files:
    trunk/ChangeLog
    trunk/lib/webrick/httpservlet/cgihandler.rb
    trunk/test/webrick/test_cgi.rb
    trunk/test/webrick/webrick.cgi
Index: lib/webrick/httpservlet/cgihandler.rb
===================================================================
--- lib/webrick/httpservlet/cgihandler.rb	(revision 55730)
+++ lib/webrick/httpservlet/cgihandler.rb	(revision 55731)
@@ -52,6 +52,7 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/httpservlet/cgihandler.rb#L52
           meta = req.meta_vars
           meta["SCRIPT_FILENAME"] = @script_filename
           meta["PATH"] = @config[:CGIPathEnv]
+          meta.delete("HTTP_PROXY")
           if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
             meta["SystemRoot"] = ENV["SystemRoot"]
           end
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55730)
+++ ChangeLog	(revision 55731)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jul 23 01:41:29 2016  Eric Wong  <e@8...>
+
+	* lib/webrick/httpservlet/cgihandler.rb (do_GET): delete HTTP_PROXY
+	* test/webrick/test_cgi.rb (test_cgi_env): new test
+	* test/webrick/webrick.cgi (do_GET): new endpoint to dump env
+	  [ruby-core:76511] [Bug #12610]
+
 Fri Jul 22 19:55:20 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* vm.c (vm_set_main_stack): remove unnecessary check.  toplevel
Index: test/webrick/test_cgi.rb
===================================================================
--- test/webrick/test_cgi.rb	(revision 55730)
+++ test/webrick/test_cgi.rb	(revision 55731)
@@ -114,6 +114,20 @@ class TestWEBrickCGI < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/webrick/test_cgi.rb#L114
     }
   end
 
+  def test_cgi_env
+    start_cgi_server do |server, addr, port, log|
+      http = Net::HTTP.new(addr, port)
+      req = Net::HTTP::Get.new("/webrick.cgi/dumpenv")
+      req['proxy'] = 'http://example.com/'
+      req['hello'] = 'world'
+      http.request(req) do |res|
+        env = Marshal.load(res.body)
+        assert_equal 'world', env['HTTP_HELLO']
+        assert_not_operator env, :include?, 'HTTP_PROXY'
+      end
+    end
+  end
+
   CtrlSeq = [0x7f, *(1..31)].pack("C*").gsub(/\s+/, '')
   CtrlPat = /#{Regexp.quote(CtrlSeq)}/o
   DumpPat = /#{Regexp.quote(CtrlSeq.dump[1...-1])}/o
Index: test/webrick/webrick.cgi
===================================================================
--- test/webrick/webrick.cgi	(revision 55730)
+++ test/webrick/webrick.cgi	(revision 55731)
@@ -4,7 +4,9 @@ require "webrick/cgi" https://github.com/ruby/ruby/blob/trunk/test/webrick/webrick.cgi#L4
 class TestApp < WEBrick::CGI
   def do_GET(req, res)
     res["content-type"] = "text/plain"
-    if (p = req.path_info) && p.length > 0
+    if req.path_info == "/dumpenv"
+      res.body = Marshal.dump(ENV.to_hash)
+    elsif (p = req.path_info) && p.length > 0
       res.body = p
     elsif (q = req.query).size > 0
       res.body = q.keys.sort.collect{|key|

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

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