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

key: :99 reports value as :"99" rather than ":99" - how to include second colon as part of the value string? #596

Open
jeffwidman opened this issue Dec 2, 2022 · 0 comments

Comments

@jeffwidman
Copy link

jeffwidman commented Dec 2, 2022

Over in dependabot/dependabot-core#5453 a user reported a parsing difficulty with the following example YAML file:

env:
  DISPLAY: :99

So I tried parsing it:

irb(main):002:0> s = Psych.safe_load('env:\n  DISPLAY: :99')
# throws exception about unable to load the `Symbol` class

irb(main):002:0> s = Psych.safe_load('env:\n  DISPLAY: :99', permitted_classes: [Symbol])
=> {"env:\\n  DISPLAY"=>:"99"}

# Now try quoting the value w/o permitting Symbol:
irb(main):003:0> w = Psych.safe_load('env:\n  DISPLAY: ":99"')
=> {"env:\\n  DISPLAY"=>":99"}

# contrast the resulting values:
irb(main):006:0> s.values[0]
=> :"99"
irb(main):007:0> w.values[0]
=> ":99"

Notice that these two values differ... :"99" rather than the expected ":99, ie symbol for "99" vs full string ":99".

Is there a way to configure Psych to treat the colon as part of the string and not a symbol indicator?

@jeffwidman jeffwidman changed the title key: :99 reports value as :"99" rather than ":99" key: :99 reports value as :"99" rather than ":99" - how to include second colon as part of the value string? Dec 2, 2022
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

1 participant