diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2022-03-22 14:21:59 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-06-01 17:06:52 +0900 |
commit | 8381c568e70519e6902302cbe2b421742759f341 (patch) | |
tree | b56fa9e921ce2e3ad84219b2abff8aa0a577cd36 | |
parent | 89ec3def74cb66e520b027e766e4874a82ddb528 (diff) | |
download | ruby-8381c568e70519e6902302cbe2b421742759f341.tar.gz |
[rubygems/rubygems] Restore ability to load old marshalled gemspec that use `YAML::PrivateType`
This issue was not detected because when all traces of old YAML parser
and emitter `Syck` were removed, this null-type.gemspec.rz marshalled
gemspec was updated to no longer load `YAML::Syck::PrivateType` but load
`Psych::PrivateType` instead.
However, realworld old marshalled gemspecs still use the
`YAML::PrivateType` constant, so this commit replaces the gemspec to be
the real pry-0.4.7 marshalled gemspec, so that it catches this issue.
https://github.com/rubygems/rubygems/commit/51b330b8d2
-rw-r--r-- | lib/rubygems/specification.rb | 9 | ||||
-rw-r--r-- | test/rubygems/data/null-type.gemspec.rz | bin | 504 -> 433 bytes |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index aaf11ebd98..b0045ba511 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -1270,7 +1270,14 @@ class Gem::Specification < Gem::BasicSpecification def self._load(str) Gem.load_yaml - array = Marshal.load str + array = begin + Marshal.load str + rescue ArgumentError => e + raise unless e.message.include?("YAML") + + Object.const_set "YAML", Psych + Marshal.load str + end spec = Gem::Specification.new spec.instance_variable_set :@specification_version, array[1] diff --git a/test/rubygems/data/null-type.gemspec.rz b/test/rubygems/data/null-type.gemspec.rz Binary files differindex 2134fcde29..58fc1ed8a0 100644 --- a/test/rubygems/data/null-type.gemspec.rz +++ b/test/rubygems/data/null-type.gemspec.rz |