Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!str and quotes ignored when loading merge keys #203

Closed
connec opened this issue Aug 29, 2014 · 2 comments
Closed

!!str and quotes ignored when loading merge keys #203

connec opened this issue Aug 29, 2014 · 2 comments

Comments

@connec
Copy link

connec commented Aug 29, 2014

a: &me { hello: world }
b: { !!str '<<': *m }

This loads as:

{
  "a": { "hello": "world" },
  "b": { "hello": "world" }
}

It should load as:

{
  "a": { "hello": "world" },
  "b": {
    "<<": { "hello": "world" }
  }
}
@connec
Copy link
Author

connec commented Aug 29, 2014

This causes issues when dumping hashes with a "<<" key and an alias:

h = {}
Psych.dump 'a' => h, 'b' => h
# => "---\na: &1 {}\nb: *1\n"
Psych.dump 'a' => h, '<<' => h
# => "---\na: &1 {}\n\"<<\": *1\n"
Psych.load _
# => {"a"=>{}}

This is pretty 'edge-casey' and unlikely to come up in real code, but it has some interesting implications for #202.

@tenderlove
Copy link
Member

I think if we fix this, then dealing with #202 becomes much easier.

tenderlove added a commit that referenced this issue Jan 8, 2015
* master: (21 commits)
  * ext/psych/lib/psych/visitors/to_ruby.rb: call `allocate` on hash subclasses.  Fixes github.com//issues/196
  * ext/psych/lib/psych/visitors/to_ruby.rb: revive hashes with ivars
  removed isolate task
  removed isolate plugin
  added minitest dependency into gemspec
  added install task into travis
  added ruby-head env
  bumping version to 2.0.8
  fixed build error caused by trunk changes
  bumping version to 2.0.7
  merging from ruby trunk
  backport r48512 from ruby/ruby trunk.
  Add changelog for 2a4d956
  backport r48214 from ruby/ruby trunk.
  Allow dumping any BasicObject that defines #marshal_dump or #marshal_load
  bumping version
  * ext/psych/lib/psych/visitors/yaml_tree.rb: fix NameError dumping and   loading. Fixes GH #85. Thanks @brentdax for the patch! * test/psych/test_exception.rb: test for fix
  * ext/psych/lib/psych/scalar_scanner.rb: fix loading strings that   look like integers but have a newline. Fixes GH #189 * test/psych/test_string.rb: test for fix
  * ext/psych/lib/psych/visitors/to_ruby.rb: merge keys with a hash   should merge the hash in to the parent. * test/psych/test_merge_keys.rb: test for change. Fixes GH #202
  * ext/psych/lib/psych/visitors/to_ruby.rb: quoted "<<" strings   should not be treated as merge keys. * ext/psych/lib/psych/visitors/yaml_tree.rb: hashes with keys   containing "<<" should roundtrip. * test/psych/test_merge_keys.rb: test for change. Fixes GH #203
  ...

Conflicts:
	lib/psych/visitors/yaml_tree.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants