Skip to content

Commit

Permalink
[rubygems/rubygems] Restore ability to load old marshalled gemspec th…
Browse files Browse the repository at this point in the history
…at 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.

rubygems/rubygems@51b330b8d2
  • Loading branch information
deivid-rodriguez authored and matzbot committed Jun 1, 2022
1 parent 89ec3de commit 8381c56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/rubygems/specification.rb
Expand Up @@ -1270,7 +1270,14 @@ def self.unresolved_deps
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]
Expand Down
Binary file modified test/rubygems/data/null-type.gemspec.rz
Binary file not shown.

0 comments on commit 8381c56

Please sign in to comment.