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

yaml parsing is wrong when key's value has leading colon #669

Open
subeditara opened this issue Jan 25, 2024 · 1 comment
Open

yaml parsing is wrong when key's value has leading colon #669

subeditara opened this issue Jan 25, 2024 · 1 comment

Comments

@subeditara
Copy link

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

@hsbt hsbt transferred this issue from ruby/yaml Jan 31, 2024
@tenderlove
Copy link
Member

I guess this is because Python doesn't have the concept of a Symbol like Ruby does?

As a work-around, this should work (untested):

ruby -ryaml -e "a = YAML.load('servers: "::ffff:10.10.10.1"'); puts a; puts a['servers']"

I'm not sure what to do about this. I'm sure there are Ruby users that well expect symbols in this case so I don't want to change the behavior.

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