From 12f3e78c9540f9c8591422586e61ce518927d10f Mon Sep 17 00:00:00 2001 From: Michael Rykov Date: Wed, 15 Jan 2025 18:12:45 +0800 Subject: [PATCH] fix `@licenses` array unmarshalling --- lib/rubygems/specification.rb | 2 +- test/rubygems/test_gem_safe_marshal.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 8f353aeddacf..35e165ff6af5 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -1322,7 +1322,7 @@ def self._load(str) spec.instance_variable_set :@description, array[13] spec.instance_variable_set :@homepage, array[14] spec.instance_variable_set :@has_rdoc, array[15] - spec.instance_variable_set :@licenses, [array[17]] + spec.instance_variable_set :@licenses, array[17] spec.instance_variable_set :@metadata, array[18] spec.instance_variable_set :@loaded, false spec.instance_variable_set :@activated, false diff --git a/test/rubygems/test_gem_safe_marshal.rb b/test/rubygems/test_gem_safe_marshal.rb index 3cfa66fb2743..deeb8205bc8b 100644 --- a/test/rubygems/test_gem_safe_marshal.rb +++ b/test/rubygems/test_gem_safe_marshal.rb @@ -353,7 +353,19 @@ def test_gem_spec_unmarshall_license unmarshalled_spec = Gem::SafeMarshal.safe_load(Marshal.dump(spec)) - assert_equal ["MIT"], unmarshalled_spec.license + assert_equal ["MIT"], unmarshalled_spec.licenses + assert_equal "MIT", unmarshalled_spec.license + + spec = Gem::Specification.new do |s| + s.name = "hi" + s.version = "1.2.3" + s.licenses = ["MIT", "GPL2"] + end + + unmarshalled_spec = Gem::SafeMarshal.safe_load(Marshal.dump(spec)) + + assert_equal ["MIT", "GPL2"], unmarshalled_spec.licenses + assert_equal "MIT", unmarshalled_spec.license end def test_gem_spec_unmarshall_required_ruby_rubygems_version