Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/psych/visitors/to_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def revive_hash hash, o, tagged= false
key = accept(k)
val = accept(v)

if key == '<<' && k.tag != "tag:yaml.org,2002:str"
if key == '<<' && k.tag != "tag:yaml.org,2002:str" && !k.quoted
case v
when Nodes::Alias, Nodes::Mapping
begin
Expand Down
7 changes: 7 additions & 0 deletions test/psych/test_merge_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ def test_explicit_string
assert_equal expected, doc
end

def test_quoted_string
expected = { "a" => "x", "<<" => { "a" => "y" } }
assert_equal expected, Psych.load("a: x\n'<<': { a: y }\n")
assert_equal expected, Psych.load("a: x\n\"<<\": { a: y }\n")
assert_equal expected, Psych.load('{"a": "x", "<<": {"a": "y"}}')
end

def test_mergekey_with_object
s = <<-eoyml
foo: &foo
Expand Down
Loading