diff options
author | Jeremy Evans <[email protected]> | 2019-08-26 21:41:27 -0700 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2019-11-30 17:48:15 +0900 |
commit | c75100d00401c32b3245ce8da5b8a045976216ca (patch) | |
tree | 6f7d753792c8971922672e99ede844d5b4af879a | |
parent | f7cf5416e471cd34153058952063da3457468e58 (diff) |
[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
-rw-r--r-- | lib/webrick/httpservlet/cgihandler.rb | 8 | ||||
-rw-r--r-- | test/webrick/test_filehandler.rb | 2 | ||||
-rw-r--r-- | test/webrick/utils.rb | 8 |
3 files changed, 16 insertions, 2 deletions
diff --git a/lib/webrick/httpservlet/cgihandler.rb b/lib/webrick/httpservlet/cgihandler.rb index 981f649750..4457770b7a 100644 --- a/lib/webrick/httpservlet/cgihandler.rb +++ b/lib/webrick/httpservlet/cgihandler.rb @@ -28,6 +28,7 @@ module WEBrick 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 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 4526b1e30a..b3f0de2621 100644 --- a/test/webrick/test_filehandler.rb +++ b/test/webrick/test_filehandler.rb @@ -289,7 +289,7 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase 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 ca9c56aca2..56d3a30ea4 100644 --- a/test/webrick/utils.rb +++ b/test/webrick/utils.rb @@ -19,6 +19,8 @@ module TestWEBrick 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 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 |