Skip to content

Commit

Permalink
Merge RubyGems-3.6.2 and Bundler-2.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and hsbt committed Dec 23, 2024
1 parent 527cc73 commit 9e0eb97
Show file tree
Hide file tree
Showing 18 changed files with 234 additions and 68 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-lock.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.SH "NAME"
\fBbundle\-lock\fR \- Creates / Updates a lockfile without installing
.SH "SYNOPSIS"
\fBbundle lock\fR [\-\-update] [\-\-bundler[=BUNDLER]] [\-\-local] [\-\-print] [\-\-lockfile=PATH] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-add\-checkums] [\-\-add\-platform] [\-\-remove\-platform] [\-\-normalize\-platforms] [\-\-patch] [\-\-minor] [\-\-major] [\-\-pre] [\-\-strict] [\-\-conservative]
\fBbundle lock\fR [\-\-update] [\-\-bundler[=BUNDLER]] [\-\-local] [\-\-print] [\-\-lockfile=PATH] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-add\-checksums] [\-\-add\-platform] [\-\-remove\-platform] [\-\-normalize\-platforms] [\-\-patch] [\-\-minor] [\-\-major] [\-\-pre] [\-\-strict] [\-\-conservative]
.SH "DESCRIPTION"
Lock the gems specified in Gemfile\.
.SH "OPTIONS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-lock.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bundle-lock(1) -- Creates / Updates a lockfile without installing
[--lockfile=PATH]
[--full-index]
[--gemfile=GEMFILE]
[--add-checkums]
[--add-checksums]
[--add-platform]
[--remove-platform]
[--normalize-platforms]
Expand Down
5 changes: 3 additions & 2 deletions lib/bundler/self_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ def restart_with(version)
require "shellwords"
cmd = [*Shellwords.shellsplit(bundler_spec_original_cmd), *ARGV]
else
cmd = [Process.argv0, *ARGV]
cmd.unshift(Gem.ruby) unless File.executable?(Process.argv0)
argv0 = File.exist?($PROGRAM_NAME) ? $PROGRAM_NAME : Process.argv0
cmd = [argv0, *ARGV]
cmd.unshift(Gem.ruby) unless File.executable?(argv0)
end

Bundler.with_original_env do
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: false

module Bundler
VERSION = "2.6.1".freeze
VERSION = "2.6.2".freeze

def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require "rbconfig"

module Gem
VERSION = "3.6.1"
VERSION = "3.6.2"
end

# Must be first since it unloads the prelude from 1.9.2
Expand Down
11 changes: 10 additions & 1 deletion lib/rubygems/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
require "rdoc/rubygems_hook"
module Gem
RDoc = ::RDoc::RubygemsHook

##
# Returns whether RDoc defines its own install hooks through a RubyGems
# plugin. This and whatever is guarded by it can be removed once no
# supported Ruby ships with RDoc older than 6.9.0.

def self.rdoc_hooks_defined_via_plugin?
Gem::Version.new(::RDoc::VERSION) >= Gem::Version.new("6.9.0")
end
end

Gem.done_installing(&Gem::RDoc.method(:generation_hook))
Gem.done_installing(&Gem::RDoc.method(:generation_hook)) unless Gem.rdoc_hooks_defined_via_plugin?
rescue LoadError
end
7 changes: 4 additions & 3 deletions lib/rubygems/requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Gem::Requirement

SOURCE_SET_REQUIREMENT = Struct.new(:for_lockfile).new "!" # :nodoc:

quoted = OPS.keys.map {|k| Regexp.quote k }.join "|"
quoted = Regexp.union(OPS.keys)
PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*".freeze # :nodoc:

##
Expand Down Expand Up @@ -201,7 +201,8 @@ def marshal_dump # :nodoc:
def marshal_load(array) # :nodoc:
@requirements = array[0]

raise TypeError, "wrong @requirements" unless Array === @requirements
raise TypeError, "wrong @requirements" unless Array === @requirements &&
@requirements.all? {|r| r.size == 2 && (r.first.is_a?(String) || r[0] = "=") && r.last.is_a?(Gem::Version) }
end

def yaml_initialize(tag, vals) # :nodoc:
Expand Down Expand Up @@ -238,7 +239,7 @@ def pretty_print(q) # :nodoc:
def satisfied_by?(version)
raise ArgumentError, "Need a Gem::Version: #{version.inspect}" unless
Gem::Version === version
requirements.all? {|op, rv| OPS[op].call version, rv }
requirements.all? {|op, rv| OPS.fetch(op).call version, rv }
end

alias_method :===, :satisfied_by?
Expand Down
45 changes: 31 additions & 14 deletions lib/rubygems/safe_marshal/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ class NotImplementedError < Error
class EOFError < Error
end

class DataTooShortError < Error
end

class NegativeLengthError < Error
end

def initialize(io)
@io = io
end

def read!
read_header
root = read_element
raise UnconsumedBytesError unless @io.eof?
raise UnconsumedBytesError, "expected EOF, got #{@io.read(10).inspect}... after top-level element #{root.class}" unless @io.eof?
root
end

Expand All @@ -41,8 +47,16 @@ def read_header
raise UnsupportedVersionError, "Unsupported marshal version #{v.bytes.map(&:ord).join(".")}, expected #{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}" unless v == MARSHAL_VERSION
end

def read_bytes(n)
raise NegativeLengthError if n < 0
str = @io.read(n)
raise EOFError, "expected #{n} bytes, got EOF" if str.nil?
raise DataTooShortError, "expected #{n} bytes, got #{str.inspect}" unless str.bytesize == n
str
end

def read_byte
@io.getbyte
@io.getbyte || raise(EOFError, "Unexpected EOF")
end

def read_integer
Expand All @@ -67,8 +81,6 @@ def read_integer
read_byte | (read_byte << 8) | -0x10000
when 0xFF
read_byte | -0x100
when nil
raise EOFError, "Unexpected EOF"
else
signed = (b ^ 128) - 128
if b >= 128
Expand Down Expand Up @@ -107,8 +119,6 @@ def read_element
when 47 then read_regexp # ?/
when 83 then read_struct # ?S
when 67 then read_user_class # ?C
when nil
raise EOFError, "Unexpected EOF"
else
raise Error, "Unknown marshal type discriminator #{type.chr.inspect} (#{type})"
end
Expand All @@ -127,7 +137,7 @@ def read_symbol
Elements::Symbol.new(byte.chr)
end
else
name = -@io.read(len)
name = read_bytes(len)
Elements::Symbol.new(name)
end
end
Expand All @@ -138,7 +148,7 @@ def read_symbol
def read_string
length = read_integer
return EMPTY_STRING if length == 0
str = @io.read(length)
str = read_bytes(length)
Elements::String.new(str)
end

Expand All @@ -152,7 +162,7 @@ def read_false

def read_user_defined
name = read_element
binary_string = @io.read(read_integer)
binary_string = read_bytes(read_integer)
Elements::UserDefined.new(name, binary_string)
end

Expand All @@ -162,6 +172,7 @@ def read_user_defined
def read_array
length = read_integer
return EMPTY_ARRAY if length == 0
raise NegativeLengthError if length < 0
elements = Array.new(length) do
read_element
end
Expand All @@ -170,7 +181,9 @@ def read_array

def read_object_with_ivars
object = read_element
ivars = Array.new(read_integer) do
length = read_integer
raise NegativeLengthError if length < 0
ivars = Array.new(length) do
[read_element, read_element]
end
Elements::WithIvars.new(object, ivars)
Expand Down Expand Up @@ -239,7 +252,9 @@ def read_hash
end

def read_hash_with_default_value
pairs = Array.new(read_integer) do
length = read_integer
raise NegativeLengthError if length < 0
pairs = Array.new(length) do
[read_element, read_element]
end
default = read_element
Expand All @@ -249,7 +264,9 @@ def read_hash_with_default_value
def read_object
name = read_element
object = Elements::Object.new(name)
ivars = Array.new(read_integer) do
length = read_integer
raise NegativeLengthError if length < 0
ivars = Array.new(length) do
[read_element, read_element]
end
Elements::WithIvars.new(object, ivars)
Expand All @@ -260,13 +277,13 @@ def read_nil
end

def read_float
string = @io.read(read_integer)
string = read_bytes(read_integer)
Elements::Float.new(string)
end

def read_bignum
sign = read_byte
data = @io.read(read_integer * 2)
data = read_bytes(read_integer * 2)
Elements::Bignum.new(sign, data)
end

Expand Down
45 changes: 29 additions & 16 deletions lib/rubygems/safe_marshal/visitors/to_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def visit_Gem_SafeMarshal_Elements_Array(a)
idx = 0
# not idiomatic, but there's a huge number of IMEMOs allocated here, so we avoid the block
# because this is such a hot path when doing a bundle install with the full index
until idx == size
while idx < size
push_stack idx
array << visit(elements[idx])
idx += 1
Expand Down Expand Up @@ -98,16 +98,21 @@ def visit_Gem_SafeMarshal_Elements_WithIvars(e)
end

s = e.object.binary_string
# 122 is the largest integer that can be represented in marshal in a single byte
raise TimeTooLargeError.new("binary string too large", stack: formatted_stack) if s.bytesize > 122

marshal_string = "\x04\bIu:\tTime".b
marshal_string.concat(s.size + 5)
marshal_string.concat(s.bytesize + 5)
marshal_string << s
# internal is limited to 5, so no overflow is possible
marshal_string.concat(internal.size + 5)

internal.each do |k, v|
k = k.name
# ivar name can't be too large because only known ivars are in the internal ivars list
marshal_string.concat(":")
marshal_string.concat(k.size + 5)
marshal_string.concat(k.to_s)
marshal_string.concat(k.bytesize + 5)
marshal_string.concat(k)
dumped = Marshal.dump(v)
dumped[0, 2] = ""
marshal_string.concat(dumped)
Expand Down Expand Up @@ -171,11 +176,11 @@ def visit_Gem_SafeMarshal_Elements_Object(o)
end

def visit_Gem_SafeMarshal_Elements_ObjectLink(o)
@objects[o.offset]
@objects.fetch(o.offset)
end

def visit_Gem_SafeMarshal_Elements_SymbolLink(o)
@symbols[o.offset]
@symbols.fetch(o.offset)
end

def visit_Gem_SafeMarshal_Elements_UserDefined(o)
Expand Down Expand Up @@ -219,16 +224,18 @@ def visit_Gem_SafeMarshal_Elements_String(s)
end

def visit_Gem_SafeMarshal_Elements_Float(f)
case f.string
when "inf"
::Float::INFINITY
when "-inf"
-::Float::INFINITY
when "nan"
::Float::NAN
else
f.string.to_f
end
register_object(
case f.string
when "inf"
::Float::INFINITY
when "-inf"
-::Float::INFINITY
when "nan"
::Float::NAN
else
f.string.to_f
end
)
end

def visit_Gem_SafeMarshal_Elements_Bignum(b)
Expand Down Expand Up @@ -374,6 +381,12 @@ def formatted_stack
class Error < StandardError
end

class TimeTooLargeError < Error
def initialize(message, stack:)
super "#{message} @ #{stack.join "."}"
end
end

class UnpermittedSymbolError < Error
def initialize(symbol:, stack:)
@symbol = symbol
Expand Down
12 changes: 2 additions & 10 deletions lib/rubygems/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1817,16 +1817,8 @@ def doc_dir(type = nil)
def encode_with(coder) # :nodoc:
coder.add "name", @name
coder.add "version", @version
platform = case @new_platform
when nil, "" then
"ruby"
when String then
@new_platform
else
@new_platform.to_s
end
coder.add "platform", platform
coder.add "original_platform", @original_platform.to_s if platform != @original_platform.to_s
coder.add "platform", platform.to_s
coder.add "original_platform", original_platform.to_s if platform.to_s != original_platform.to_s

attributes = @@attributes.map(&:to_s) - %w[name version platform]
attributes.each do |name|
Expand Down
1 change: 0 additions & 1 deletion lib/rubygems/uninstaller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
require_relative "../rubygems"
require_relative "installer_uninstaller_utils"
require_relative "dependency_list"
require_relative "rdoc"
require_relative "user_interaction"

##
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/vendor/net-http/lib/net/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ class HTTPHeaderSyntaxError < StandardError; end
#
# First, what's elsewhere. Class Gem::Net::HTTP:
#
# - Inherits from {class Object}[https://docs.ruby-lang.org/en/master/Object.html#class-Object-label-What-27s+Here].
# - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
#
# This is a categorized summary of methods and attributes.
#
Expand Down
5 changes: 4 additions & 1 deletion lib/rubygems/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ def marshal_dump
# 1.3.5 and earlier) compatibility.

def marshal_load(array)
initialize array[0]
string = array[0]
raise TypeError, "wrong version string" unless string.is_a?(String)

initialize string
end

def yaml_initialize(tag, map) # :nodoc:
Expand Down
Loading

0 comments on commit 9e0eb97

Please sign in to comment.