yaml parsing is wrong when key's value has leading colon
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 597
- Forks
- 223
- Avg merge
- 11h 23m
- Merged PRs (30d)
- 3
Description
replication steps:
ruby -ryaml -e "a = YAML.load('servers: ::ffff:10.10.10.1'); puts a; puts a['servers']"
{"servers"=>:":ffff:10.10.10.1"}
:ffff:10.10.10.1
expected:
{"servers"=>"::ffff:10.10.10.1"}
::ffff:10.10.10.1
actual result:
{"servers"=>:":ffff:10.10.10.1"}
:ffff:10.10.10.1
Environment:
ruby --version
ruby 2.7.0p0
gem list yaml
yaml (0.3.0)
Python yaml works as expected:
python3.9 -c 'import yaml; a=yaml.safe_load("servers: ::ffff:10.10.10.1"); print(a); print(a["servers"]);'
{'servers': '::ffff:10.10.10.1'}
::ffff:10.10.10.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the result with the Ruby YAML.load command shown in the issue, then trace how that input is handled by Psych and its libyaml wrapper. The fix is done when the leading double colon remains part of the scalar value and the displayed hash and value match the expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100