Module: Gem::SafeMarshal

Defined in:
lib/rubygems/safe_marshal.rb,
lib/rubygems/safe_marshal/reader.rb,
lib/rubygems/safe_marshal/elements.rb,
lib/rubygems/safe_marshal/visitors/to_ruby.rb,
lib/rubygems/safe_marshal/visitors/stream_printer.rb

Overview

This module is used for safely loading Marshal specs from a gem. The ‘safe_load` method defined on this module is specifically designed for loading Gem specifications.

Defined Under Namespace

Modules: Elements, Visitors Classes: Reader

Class Method Summary collapse

Class Method Details

.load(input, permitted_classes: [::Symbol], permitted_symbols: [], permitted_ivars: {}) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/rubygems/safe_marshal.rb', line 64

def self.load(input, permitted_classes: [::Symbol], permitted_symbols: [], permitted_ivars: {})
  root = Reader.new(StringIO.new(input, "r").binmode).read!

  Visitors::ToRuby.new(
    permitted_classes: permitted_classes,
    permitted_symbols: permitted_symbols,
    permitted_ivars: permitted_ivars,
  ).visit(root)
end

.safe_load(input) ⇒ Object



60
61
62
# File 'lib/rubygems/safe_marshal.rb', line 60

def self.safe_load(input)
  load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, permitted_ivars: PERMITTED_IVARS)
end