From 8381c568e70519e6902302cbe2b421742759f341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 22 Mar 2022 14:21:59 +0100 Subject: [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 --- lib/rubygems/specification.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/rubygems/specification.rb') 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] -- cgit v1.2.3