Check if Kernel#untaint
is defined instead of version comparison
Probably `RUBY_VERSION` seems overwritten somewhere in the tests.
This commit is contained in:
parent
1f877fa238
commit
9736cb890b
Notes:
git
2021-12-27 08:56:21 +09:00
Merged: https://github.com/ruby/ruby/pull/5349 Merged-By: nobu <nobu@ruby-lang.org>
@ -46,7 +46,7 @@ module Bundler
|
|||||||
@gemfile = expanded_gemfile_path
|
@gemfile = expanded_gemfile_path
|
||||||
@gemfiles << expanded_gemfile_path
|
@gemfiles << expanded_gemfile_path
|
||||||
contents ||= Bundler.read_file(@gemfile.to_s)
|
contents ||= Bundler.read_file(@gemfile.to_s)
|
||||||
instance_eval(contents.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
|
instance_eval(contents.dup.tap{|x| x.untaint if Kernel.method_defined?(:untaint) }, gemfile.to_s, 1)
|
||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
message = "There was an error " \
|
message = "There was an error " \
|
||||||
"#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
|
"#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
|
||||||
|
@ -29,7 +29,7 @@ module Gem
|
|||||||
# gems at that time, this method could be called inside another require,
|
# gems at that time, this method could be called inside another require,
|
||||||
# thus raising with that constant being undefined. Better to check a method
|
# thus raising with that constant being undefined. Better to check a method
|
||||||
if source.respond_to?(:path) || (source.respond_to?(:bundler_plugin_api_source?) && source.bundler_plugin_api_source?)
|
if source.respond_to?(:path) || (source.respond_to?(:bundler_plugin_api_source?) && source.bundler_plugin_api_source?)
|
||||||
Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
|
Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap{|x| x.untaint if Kernel.method_defined?(:untaint) }
|
||||||
else
|
else
|
||||||
rg_full_gem_path
|
rg_full_gem_path
|
||||||
end
|
end
|
||||||
|
@ -13,13 +13,13 @@ module Bundler
|
|||||||
def root
|
def root
|
||||||
gemfile = find_gemfile
|
gemfile = find_gemfile
|
||||||
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
|
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
|
||||||
Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
|
Pathname.new(gemfile).tap{|x| x.untaint if Kernel.method_defined?(:untaint) }.expand_path.parent
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_gemfile
|
def default_gemfile
|
||||||
gemfile = find_gemfile
|
gemfile = find_gemfile
|
||||||
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
|
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
|
||||||
Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
|
Pathname.new(gemfile).tap{|x| x.untaint if Kernel.method_defined?(:untaint) }.expand_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_lockfile
|
def default_lockfile
|
||||||
@ -28,7 +28,7 @@ module Bundler
|
|||||||
case gemfile.basename.to_s
|
case gemfile.basename.to_s
|
||||||
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
|
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
|
||||||
else Pathname.new("#{gemfile}.lock")
|
else Pathname.new("#{gemfile}.lock")
|
||||||
end.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
|
end.tap{|x| x.untaint if Kernel.method_defined?(:untaint) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_bundle_dir
|
def default_bundle_dir
|
||||||
@ -100,7 +100,7 @@ module Bundler
|
|||||||
#
|
#
|
||||||
# @see {Bundler::PermissionError}
|
# @see {Bundler::PermissionError}
|
||||||
def filesystem_access(path, action = :write, &block)
|
def filesystem_access(path, action = :write, &block)
|
||||||
yield(path.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" })
|
yield(path.dup.tap{|x| x.untaint if Kernel.method_defined?(:untaint) })
|
||||||
rescue Errno::EACCES
|
rescue Errno::EACCES
|
||||||
raise PermissionError.new(path, action)
|
raise PermissionError.new(path, action)
|
||||||
rescue Errno::EAGAIN
|
rescue Errno::EAGAIN
|
||||||
@ -236,7 +236,7 @@ module Bundler
|
|||||||
|
|
||||||
def search_up(*names)
|
def search_up(*names)
|
||||||
previous = nil
|
previous = nil
|
||||||
current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if RUBY_VERSION < "2.7" }
|
current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if Kernel.method_defined?(:untaint) }
|
||||||
|
|
||||||
until !File.directory?(current) || current == previous
|
until !File.directory?(current) || current == previous
|
||||||
if ENV["BUNDLER_SPEC_RUN"]
|
if ENV["BUNDLER_SPEC_RUN"]
|
||||||
|
@ -336,7 +336,7 @@ module Bundler
|
|||||||
|
|
||||||
def load_gemspec(file)
|
def load_gemspec(file)
|
||||||
stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
|
stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
|
||||||
stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
|
stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap{|x| x.untaint if Kernel.method_defined?(:untaint) }
|
||||||
StubSpecification.from_stub(stub)
|
StubSpecification.from_stub(stub)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user