Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
View
6 lib/rubygems/specification.rb
@@ -561,7 +561,11 @@ def self.non_nil_attributes
def self.normalize_yaml_input(input)
result = input.respond_to?(:read) ? input.read : input
result = "--- " + result unless result =~ /\A--- /
- result.gsub(/ !!null \n/, " \n")
+ result.gsub!(/ !!null \n/, " \n")
+ # date: 2011-04-26 00:00:00.000000000Z
+ # date: 2011-04-26 00:00:00.000000000 Z
+ result.gsub!(/^(date: \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+?)Z/, '\1 Z')
+ result
end
##
View
32 test/rubygems/test_gem_specification.rb
@@ -114,6 +114,20 @@ def test_self__load_future
assert_equal @current_version, new_spec.specification_version
end
+ def test_self_from_yaml_syck_bug
+ # This is equivalent to (and totally valid) psych 1.0 output and
+ # causes parse errors on syck.
+ yaml = @a1.to_yaml
+ yaml.sub!(/^date:.*/, "date: 2011-04-26 00:00:00.000000000Z")
+
+ new_spec = with_syck do
+ Gem::Specification.from_yaml yaml
+ end
+
+ assert_kind_of Time, @a1.date
+ assert_kind_of Time, new_spec.date
+ end
+
def test_self_load
full_path = @a2.spec_file
write_file full_path do |io|
@@ -1386,4 +1400,22 @@ def util_setup_validate
end
end
end
+
+ def with_syck
+ begin
+ require "yaml"
+ old_engine = YAML::ENGINE.yamler
+ YAML::ENGINE.yamler = 'syck'
+ rescue NameError
+ # probably on 1.8, ignore
+ end
+
+ yield
+ ensure
+ begin
+ YAML::ENGINE.yamler = old_engine
+ rescue NameError
+ # ignore
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.