Sha256: 6def0e672c53ed400713be7f4ef77faf0d566297da630fb3574363d766596378

Contents?: true

Size: 889 Bytes

Versions: 89

Compression:

Stored size: 889 Bytes

Contents

require 'safe_yaml/load'
require 'yaml/store'

module SafeYAML

  class Store < YAML::Store

    # Override YAML::Store#initialize to accept additional option
    # +safe_yaml_opts+.
    def initialize(file_name, yaml_opts = {}, safe_yaml_opts = {})
      @safe_yaml_opts = safe_yaml_opts
      super(file_name, yaml_opts)
    end

    # Override YAML::Store#load to use SafeYAML.load instead of
    # YAML.load (via #safe_yaml_load).
    #--
    # PStore#load is private, while YAML::Store#load is public.
    #++
    def load(content)
      table = safe_yaml_load(content)
      table == false ? {} : table
    end

    private

    if SafeYAML::YAML_ENGINE == 'psych'
      def safe_yaml_load(content)
        SafeYAML.load(content, nil, @safe_yaml_opts)
      end
    else
      def safe_yaml_load(content)
        SafeYAML.load(content, @safe_yaml_opts)
      end
    end

  end

end

Version data entries

89 entries across 74 versions & 7 rubygems

Version Path
brakeman-6.1.1 bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-6.1.0 bundle/ruby/3.1.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-6.0.1 bundle/ruby/3.1.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-6.0.0 bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.4.1 bundle/ruby/3.1.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.4.0 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.3.1 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.3.0 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.2.3 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.2.2 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.2.1 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.2.0 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.1.2 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.1.1 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.1.0 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.0.4 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.0.2 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.0.1 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-5.0.0 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
brakeman-4.10.1 bundle/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb