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

ruby-changes:58990

From: Jeremy <ko1@a...>
Date: Sat, 30 Nov 2019 21:30:02 +0900 (JST)
Subject: [ruby-changes:58990] c75100d004 (master): [ruby/webrick] Allow WEBrick::HTTPServlet::CGIHandler :CGIInterpreter option to be array

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

From c75100d00401c32b3245ce8da5b8a045976216ca Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Mon, 26 Aug 2019 21:41:27 -0700
Subject: [ruby/webrick] Allow WEBrick::HTTPServlet::CGIHandler :CGIInterpreter
 option to be array

This way you don't need to escape each entry.

Implements Ruby Feature 15170.

https://github.com/ruby/webrick/commit/d8086e600c

diff --git a/lib/webrick/httpservlet/cgihandler.rb b/lib/webrick/httpservlet/cgihandler.rb
index 981f649..4457770 100644
--- a/lib/webrick/httpservlet/cgihandler.rb
+++ b/lib/webrick/httpservlet/cgihandler.rb
@@ -28,6 +28,7 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/httpservlet/cgihandler.rb#L28
     class CGIHandler < AbstractServlet
       Ruby = RbConfig.ruby # :nodoc:
       CGIRunner = "\"#{Ruby}\" \"#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb\"" # :nodoc:
+      CGIRunnerArray = [Ruby, "#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb".freeze].freeze # :nodoc:
 
       ##
       # Creates a new CGI script servlet for the script at +name+
@@ -36,7 +37,12 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/httpservlet/cgihandler.rb#L37
         super(server, name)
         @script_filename = name
         @tempdir = server[:TempDir]
-        @cgicmd = "#{CGIRunner} #{server[:CGIInterpreter]}"
+        interpreter = server[:CGIInterpreter]
+        if interpreter.is_a?(Array)
+          @cgicmd = CGIRunnerArray + interpreter
+        else
+          @cgicmd = "#{CGIRunner} #{interpreter}"
+        end
       end
 
       # :stopdoc:
diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb
index 4526b1e..b3f0de2 100644
--- a/test/webrick/test_filehandler.rb
+++ b/test/webrick/test_filehandler.rb
@@ -289,7 +289,7 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/webrick/test_filehandler.rb#L289
     return if File.executable?(__FILE__) # skip on strange file system
 
     config = {
-      :CGIInterpreter => TestWEBrick::RubyBin,
+      :CGIInterpreter => TestWEBrick::RubyBinArray,
       :DocumentRoot => File.dirname(__FILE__),
       :CGIPathEnv => ENV['PATH'],
       :RequestCallback => Proc.new{|req, res|
diff --git a/test/webrick/utils.rb b/test/webrick/utils.rb
index ca9c56a..56d3a30 100644
--- a/test/webrick/utils.rb
+++ b/test/webrick/utils.rb
@@ -19,6 +19,8 @@ module TestWEBrick https://github.com/ruby/ruby/blob/trunk/test/webrick/utils.rb#L19
     Ruby = EnvUtil.rubybin
     remove_const :CGIRunner
     CGIRunner = "\"#{Ruby}\" \"#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb\"" # :nodoc:
+    remove_const :CGIRunnerArray
+    CGIRunnerArray = [Ruby, "#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb"] # :nodoc:
   end
 
   RubyBin = "\"#{EnvUtil.rubybin}\""
@@ -27,6 +29,12 @@ module TestWEBrick https://github.com/ruby/ruby/blob/trunk/test/webrick/utils.rb#L29
   RubyBin << " \"-I#{File.dirname(EnvUtil.rubybin)}/.ext/common\""
   RubyBin << " \"-I#{File.dirname(EnvUtil.rubybin)}/.ext/#{RUBY_PLATFORM}\""
 
+  RubyBinArray = [EnvUtil.rubybin]
+  RubyBinArray << "--disable-gems"
+  RubyBinArray << "-I" << "#{File.expand_path("../..", File.dirname(__FILE__))}/lib"
+  RubyBinArray << "-I" << "#{File.dirname(EnvUtil.rubybin)}/.ext/common"
+  RubyBinArray << "-I" << "#{File.dirname(EnvUtil.rubybin)}/.ext/#{RUBY_PLATFORM}"
+
   require "test/unit" unless defined?(Test::Unit)
   include Test::Unit::Assertions
   extend Test::Unit::Assertions
-- 
cgit v0.10.2


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

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