Permalink
Browse files

- Prevent Syck DefaultKey infecting ruby-format specifications

  • Loading branch information...
drbrain committed Aug 25, 2011
1 parent efe29b5 commit 11ba6639d4b30d805a08af26c01a61dbaf380b73
Showing with 36 additions and 2 deletions.
  1. +3 −0 lib/rubygems/requirement.rb
  2. +1 −1 lib/rubygems/specification.rb
  3. +32 −1 test/rubygems/test_gem_specification.rb
@@ -17,6 +17,9 @@ module YAML
if !defined? Syck
module Syck
class DefaultKey
+ def to_s
+ '='
+ end
end
end
end
@@ -1743,7 +1743,7 @@ def matches_for_glob glob # TODO: rename?
# TODO: do we need these?? Kill it
glob = File.join(self.lib_dirs_glob, glob)
- Dir[glob].map { |f| f.untaint } # FIX our tests are brokey, run w/ SAFE=1
+ Dir[glob].map { |f| f.untaint } # FIX our tests are broken, run w/ SAFE=1
end
##
@@ -115,7 +115,7 @@ def test_self__load_future
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
@@ -129,6 +129,37 @@ def test_self_from_yaml_syck_bug
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
+ YAML
+
+ new_spec = with_syck do
+ Gem::Specification.from_yaml yaml
+ end
+
+ refute_match /DefaultKey/, new_spec.to_ruby
+ end
+
def test_self_load
full_path = @a2.spec_file
write_file full_path do |io|

0 comments on commit 11ba663

Please sign in to comment.