summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-05 19:15:40 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-05 19:15:40 +0000
commit9ae2651d1929891a443eb6a208fb1038c23b86e0 (patch)
treee3de90b082f45e963a3a196708cdad260a8abf02 /ext/psych/lib/psych
parent7835e321ea05b3176f05f9840b7082b4378edc62 (diff)
* ext/psych/lib/psych/visitors/to_ruby.rb: process merge keys before
reviving objects. Fixes GH psych #168 * test/psych/test_merge_keys.rb: test for change https://github.com/tenderlove/psych/issues/168 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/lib/psych')
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb14
1 files changed, 5 insertions, 9 deletions
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index 8695fd475e..1bfffb952f 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -156,7 +156,7 @@ module Psych
if Psych.load_tags[o.tag]
return revive(resolve_class(Psych.load_tags[o.tag]), o)
end
- return revive_hash({}, o) unless o.tag
+ return revive_hash(register(o, {}), o) unless o.tag
case o.tag
when /^!ruby\/struct:?(.*)?$/
@@ -256,7 +256,7 @@ module Psych
set
when /^!map:(.*)$/, /^!ruby\/hash:(.*)$/
- revive_hash resolve_class($1).new, o
+ revive_hash register(o, resolve_class($1).new), o
when '!omap', 'tag:yaml.org,2002:omap'
map = register(o, class_loader.psych_omap.new)
@@ -266,7 +266,7 @@ module Psych
map
else
- revive_hash({}, o)
+ revive_hash(register(o, {}), o)
end
end
@@ -295,8 +295,6 @@ module Psych
end
def revive_hash hash, o
- @st[o.anchor] = hash if o.anchor
-
o.children.each_slice(2) { |k,v|
key = accept(k)
val = accept(v)
@@ -334,10 +332,8 @@ module Psych
end
def revive klass, node
- s = klass.allocate
- @st[node.anchor] = s if node.anchor
- h = Hash[*node.children.map { |c| accept c }]
- init_with(s, h, node)
+ s = register(node, klass.allocate)
+ init_with(s, revive_hash({}, node), node)
end
def init_with o, h, node