ruby / ruby/psych

psych quoting strings if they begin with dash.

Open
#482 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
597
Forks
223
Avg merge
11h 23m
Merged PRs (30d)
3

Description

Strings are quoted if they begin with a dash. This is causing issues for an external parser I'm forced to use and inquiring because of the difference in behaviour with python's yaml module.

irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> puts YAML.dump({'key' => 'value' })
---
key: value
=> nil
irb(main):003:0> puts YAML.dump({'key' => '-value' })
---
key: "-value"
=> nil
irb(main):004:0> puts YAML.dump({'-key' => '-value' })
---
"-key": "-value"
=> nil

Compared to python

>>> import yaml
>>> print(yaml.dump({'key': 'value'}))
key: value

>>> print(yaml.dump({'key': '-value'}))
key: -value

>>> print(yaml.dump({'-key': '-value'}))
-key: -value

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the YAML.dump examples from the issue and inspect Psych's scalar and mapping-key emission path. Done means dash-leading string values and keys serialize without unnecessary quotes while remaining valid YAML and preserving existing safety behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.