Sha256: 766db7f4e1ece786a6e5b64196588cb32319adeca1eecb59d034882576c6c206

Contents?: true

Size: 866 Bytes

Versions: 7

Compression:

Stored size: 866 Bytes

Contents

# frozen_string_literal: true

module Gem
  ###
  # This module is used for safely loading YAML specs from a gem.  The
  # `safe_load` method defined on this module is specifically designed for
  # loading Gem specifications.  For loading other YAML safely, please see
  # Psych.safe_load

  module SafeYAML
    PERMITTED_CLASSES = %w[
      Symbol
      Time
      Date
      Gem::Dependency
      Gem::Platform
      Gem::Requirement
      Gem::Specification
      Gem::Version
      Gem::Version::Requirement
    ].freeze

    PERMITTED_SYMBOLS = %w[
      development
      runtime
    ].freeze

    def self.safe_load(input)
      ::Psych.safe_load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, aliases: true)
    end

    def self.load(input)
      ::Psych.safe_load(input, permitted_classes: [::Symbol])
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubygems-update-3.5.6 lib/rubygems/safe_yaml.rb
rubygems-update-3.5.5 lib/rubygems/safe_yaml.rb
rubygems-update-3.5.4 lib/rubygems/safe_yaml.rb
rubygems-update-3.5.3 lib/rubygems/safe_yaml.rb
rubygems-update-3.5.2 lib/rubygems/safe_yaml.rb
rubygems-update-3.5.1 lib/rubygems/safe_yaml.rb
rubygems-update-3.5.0 lib/rubygems/safe_yaml.rb