diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2023-08-24 09:23:02 -0700 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-09-20 02:03:03 +0000 |
commit | cadca9f67eba9e101558aa32594646c3ece17c31 (patch) | |
tree | 6a4916dce734e33a9b96b2d9f981df8f37153fff /lib/rubygems | |
parent | c65c88e65c0d1c175dd2c33708b488e3f8268fda (diff) | |
download | ruby-cadca9f67eba9e101558aa32594646c3ece17c31.tar.gz |
[rubygems/rubygems] All rubies working with different time zones
Tested with:
`ruby -e 'trap("INT") { exit 1 }; TZ=%w[UTC +0000 -0000]; RUBY=%w[ruby-2.7 ruby-3.2.2 jruby-9.4 truffleruby-22 truffleruby-23]; TZ.product(RUBY).each { |t, r| puts ?**120, "TZ=#{t} RUBY=#{r}", "*"*120; system({"TZ"=>t,"RUBY"=>r}, *ARGV) }' zsh -lic 'chruby $RUBY; ruby -vw -Ilib test/rubygems/test_gem_safe_marshal.rb --verbose=progress'`
https://github.com/rubygems/rubygems/commit/6192005afb
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/safe_marshal.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/safe_marshal/visitors/to_ruby.rb | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/rubygems/safe_marshal.rb b/lib/rubygems/safe_marshal.rb index d308f2d65f..b81d1a0a47 100644 --- a/lib/rubygems/safe_marshal.rb +++ b/lib/rubygems/safe_marshal.rb @@ -42,7 +42,7 @@ module Gem private_constant :PERMITTED_SYMBOLS PERMITTED_IVARS = { - "String" => %w[E @taguri @debug_created_info], + "String" => %w[E encoding @taguri @debug_created_info], "Time" => %w[ offset zone nano_num nano_den submicro @_zone @marshal_with_utc_coercion diff --git a/lib/rubygems/safe_marshal/visitors/to_ruby.rb b/lib/rubygems/safe_marshal/visitors/to_ruby.rb index 81c5c536d5..d1e6e8669d 100644 --- a/lib/rubygems/safe_marshal/visitors/to_ruby.rb +++ b/lib/rubygems/safe_marshal/visitors/to_ruby.rb @@ -54,7 +54,6 @@ module Gem::SafeMarshal end def visit_Gem_SafeMarshal_Elements_WithIvars(e) - idx = 0 object_offset = @objects.size @stack << "object" object = visit(e.object) @@ -104,8 +103,9 @@ module Gem::SafeMarshal if zone require "time" - zone = "+0000" if zone == "UTC" && offset == 0 - call_method(Time, :force_zone!, object, zone, offset) + transformed_zone = zone + transformed_zone = "+0000" if ["UTC", "Z"].include?(zone) && offset == 0 + call_method(Time, :force_zone!, object, transformed_zone, offset) elsif offset object = object.localtime offset end @@ -131,8 +131,10 @@ module Gem::SafeMarshal when FalseClass enc = "US-ASCII" else - enc = v + raise FormatError, "Unexpected value for String :E #{v.inspect}" end + when :encoding + enc = v else next false end |