Sha256: fedbff5a117e2f2bf101a886369f6629dea1b95967114782468dd7ced27a8c1d

Contents?: true

Size: 1.04 KB

Versions: 265

Compression:

Stored size: 1.04 KB

Contents

module SafeYAML
  class PsychResolver < Resolver
    NODE_TYPES = {
      Psych::Nodes::Document => :root,
      Psych::Nodes::Mapping  => :map,
      Psych::Nodes::Sequence => :seq,
      Psych::Nodes::Scalar   => :scalar,
      Psych::Nodes::Alias    => :alias
    }.freeze

    def initialize(options={})
      super
      @aliased_nodes = {}
    end

    def resolve_root(root)
      resolve_seq(root).first
    end

    def resolve_alias(node)
      resolve_node(@aliased_nodes[node.anchor])
    end

    def native_resolve(node)
      @visitor ||= SafeYAML::SafeToRubyVisitor.new(self)
      @visitor.accept(node)
    end

    def get_node_type(node)
      NODE_TYPES[node.class]
    end

    def get_node_tag(node)
      node.tag
    end

    def get_node_value(node)
      @aliased_nodes[node.anchor] = node if node.respond_to?(:anchor) && node.anchor

      case get_node_type(node)
      when :root, :map, :seq
        node.children
      when :scalar
        node.value
      end
    end

    def value_is_quoted?(node)
      node.quoted
    end
  end
end

Version data entries

265 entries across 243 versions & 17 rubygems

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