aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_specification.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-26 01:10:50 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-26 01:10:50 +0000
commite93d882d96cc536857e6c181b5f0194f15316b7d (patch)
treed5810ac15991fc2d4eeb19138e49ba4b892e866d /test/rubygems/test_gem_specification.rb
parent4544b3824c8ce74e0a92c58a3167f900904f506b (diff)
downloadruby-e93d882d96cc536857e6c181b5f0194f15316b7d.tar.gz
* lib/rubygems: Update to RubyGems 1.8.10. Fixes security issue in
creating ruby-format gemspecs. Fixes Gem.dir not being at the front of Gem.path to fix uninstall and cleanup commands. Fixes gem uninstall stopping on the first missing gem. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_specification.rb')
-rw-r--r--test/rubygems/test_gem_specification.rb158
1 files changed, 119 insertions, 39 deletions
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 0ca1a0a94a..717710b940 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -114,7 +114,7 @@ end
assert_equal @current_version, new_spec.specification_version
end
- def test_self_from_yaml_syck_bug
+ def test_self_from_yaml_syck_date_bug
# This is equivalent to (and totally valid) psych 1.0 output and
# causes parse errors on syck.
yaml = @a1.to_yaml
@@ -128,6 +128,41 @@ end
assert_kind_of Time, new_spec.date
end
+ def test_self_from_yaml_syck_default_key_bug
+ skip 'syck default_key bug is only for ruby 1.8' unless RUBY_VERSION < '1.9'
+ # This is equivalent to (and totally valid) psych 1.0 output and
+ # causes parse errors on syck.
+ yaml = <<-YAML
+--- !ruby/object:Gem::Specification
+name: posix-spawn
+version: !ruby/object:Gem::Version
+ version: 0.3.6
+ prerelease:
+dependencies:
+- !ruby/object:Gem::Dependency
+ name: rake-compiler
+ requirement: &70243867725240 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - =
+ - !ruby/object:Gem::Version
+ version: 0.7.6
+ type: :development
+ prerelease: false
+ version_requirements: *70243867725240
+platform: ruby
+files: []
+test_files: []
+bindir:
+ YAML
+
+ new_spec = with_syck do
+ Gem::Specification.from_yaml yaml
+ end
+
+ refute_match %r%DefaultKey%, new_spec.to_ruby
+ end
+
def test_self_load
full_path = @a2.spec_file
write_file full_path do |io|
@@ -141,6 +176,51 @@ end
assert_equal @a2, spec
end
+ def test_self_load_escape_curly
+ @a2.name = 'a};raise "improper escaping";%q{'
+
+ full_path = @a2.spec_file
+ write_file full_path do |io|
+ io.write @a2.to_ruby_for_cache
+ end
+
+ spec = Gem::Specification.load full_path
+
+ @a2.files.clear
+
+ assert_equal @a2, spec
+ end
+
+ def test_self_load_escape_interpolation
+ @a2.name = 'a#{raise %<improper escaping>}'
+
+ full_path = @a2.spec_file
+ write_file full_path do |io|
+ io.write @a2.to_ruby_for_cache
+ end
+
+ spec = Gem::Specification.load full_path
+
+ @a2.files.clear
+
+ assert_equal @a2, spec
+ end
+
+ def test_self_load_escape_quote
+ @a2.name = 'a";raise "improper escaping";"'
+
+ full_path = @a2.spec_file
+ write_file full_path do |io|
+ io.write @a2.to_ruby_for_cache
+ end
+
+ spec = Gem::Specification.load full_path
+
+ @a2.files.clear
+
+ assert_equal @a2, spec
+ end
+
def test_self_load_legacy_ruby
spec = Deprecate.skip_during do
eval LEGACY_RUBY_SPEC
@@ -754,19 +834,19 @@ end
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
- s.name = %q{a}
- s.version = \"2\"
+ s.name = "a"
+ s.version = "2"
s.required_rubygems_version = Gem::Requirement.new(\"> 0\") if s.respond_to? :required_rubygems_version=
- s.authors = [%q{A User}]
- s.date = %q{#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}}
- s.description = %q{This is a test description}
- s.email = %q{example@example.com}
- s.files = [%q{lib/code.rb}]
- s.homepage = %q{http://example.com}
- s.require_paths = [%q{lib}]
- s.rubygems_version = %q{#{Gem::VERSION}}
- s.summary = %q{this is a summary}
+ s.authors = ["A User"]
+ s.date = "#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}"
+ s.description = "This is a test description"
+ s.email = "example@example.com"
+ s.files = ["lib/code.rb"]
+ s.homepage = "http://example.com"
+ s.require_paths = ["lib"]
+ s.rubygems_version = "#{Gem::VERSION}"
+ s.summary = "this is a summary"
if s.respond_to? :specification_version then
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION}
@@ -801,18 +881,18 @@ end
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
- s.name = %q{a}
- s.version = \"2\"
+ s.name = "a"
+ s.version = "2"
s.required_rubygems_version = Gem::Requirement.new(\"> 0\") if s.respond_to? :required_rubygems_version=
- s.authors = [%q{A User}]
- s.date = %q{#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}}
- s.description = %q{This is a test description}
- s.email = %q{example@example.com}
- s.homepage = %q{http://example.com}
- s.require_paths = [%q{lib}]
- s.rubygems_version = %q{#{Gem::VERSION}}
- s.summary = %q{this is a summary}
+ s.authors = ["A User"]
+ s.date = "#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}"
+ s.description = "This is a test description"
+ s.email = "example@example.com"
+ s.homepage = "http://example.com"
+ s.require_paths = ["lib"]
+ s.rubygems_version = "#{Gem::VERSION}"
+ s.summary = "this is a summary"
if s.respond_to? :specification_version then
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION}
@@ -848,26 +928,26 @@ end
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
- s.name = %q{a}
- s.version = \"1\"
+ s.name = "a"
+ s.version = "1"
s.platform = Gem::Platform.new(#{expected_platform})
s.required_rubygems_version = Gem::Requirement.new(\">= 0\") if s.respond_to? :required_rubygems_version=
- s.authors = [%q{A User}]
- s.date = %q{#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}}
- s.description = %q{This is a test description}
- s.email = %q{example@example.com}
- s.executables = [%q{exec}]
- s.extensions = [%q{ext/a/extconf.rb}]
- s.files = [%q{lib/code.rb}, %q{test/suite.rb}, %q{bin/exec}, %q{ext/a/extconf.rb}]
- s.homepage = %q{http://example.com}
- s.licenses = [%q{MIT}]
- s.require_paths = [%q{lib}]
- s.requirements = [%q{A working computer}]
- s.rubyforge_project = %q{example}
- s.rubygems_version = %q{#{Gem::VERSION}}
- s.summary = %q{this is a summary}
- s.test_files = [%q{test/suite.rb}]
+ s.authors = ["A User"]
+ s.date = "#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}"
+ s.description = "This is a test description"
+ s.email = "example@example.com"
+ s.executables = ["exec"]
+ s.extensions = ["ext/a/extconf.rb"]
+ s.files = ["lib/code.rb", "test/suite.rb", "bin/exec", "ext/a/extconf.rb"]
+ s.homepage = "http://example.com"
+ s.licenses = ["MIT"]
+ s.require_paths = ["lib"]
+ s.requirements = ["A working computer"]
+ s.rubyforge_project = "example"
+ s.rubygems_version = "#{Gem::VERSION}"
+ s.summary = "this is a summary"
+ s.test_files = ["test/suite.rb"]
if s.respond_to? :specification_version then
s.specification_version = 3