aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/test_case.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/test_case.rb')
-rw-r--r--lib/rubygems/test_case.rb21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 718571ea57..fc9456709f 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -1319,9 +1319,26 @@ Also, a list:
end
end
+ class << self
+ # :nodoc:
+ ##
+ # Return the join path, with escaping backticks, dollars, and
+ # double-quotes. Unlike `shellescape`, equal-sign is not escaped.
+ private
+ def escape_path(*path)
+ path = File.join(*path)
+ if %r'\A[-+:/=@,.\w]+\z' =~ path
+ path
+ else
+ "\"#{path.gsub(/[`$"]/, '\\&')}\""
+ end
+ end
+ end
+
@@ruby = rubybin
- @@good_rake = "#{rubybin} \"#{File.expand_path('../../../test/rubygems/good_rake.rb', __FILE__)}\""
- @@bad_rake = "#{rubybin} \"#{File.expand_path('../../../test/rubygems/bad_rake.rb', __FILE__)}\""
+ gempath = File.expand_path('../../../test/rubygems', __FILE__)
+ @@good_rake = "#{rubybin} #{escape_path(gempath, 'good_rake.rb')}"
+ @@bad_rake = "#{rubybin} #{escape_path(gempath, 'bad_rake.rb')}"
##
# Construct a new Gem::Dependency.