ruby / ruby/psych

Strings that could be interpreted as sexagesimal should always be emitted quoted

Open
#387 3 comments 1 reaction 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

Not doing so causes parsers that follow the yaml 1.1 spec (crazy though it might be), to load certain unquoted mac addresses as integers.

IMO https://github.com/ruby/psych/issues/265 wasn't actually a bug. It was following the 1.1 spec. (To make things more complicated, sexagesimal was dropped from yaml in the 1.2 spec)

Ruby 2.5 and 2.6 emit mac addresses, (but not shorter strings it thinks are more likely to be sexagesimal), unquoted.

2.6.0 :002 > '52:54:00:44:49:56'.to_yaml
 => "--- 52:54:00:44:49:56\n...\n" 
2.6.0 :003 > '44:49:56'.to_yaml
 => "--- '44:49:56'\n"

ruby < 2.5 then parse them as integers.

2.4.5 :006 >   YAML.load('macaddress: 52:54:00:44:49:56')
 => {"macaddress"=>12465480}

Here is an actual example of where the change in handling of sexagesimal has been a problem.

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 tracing the to_yaml emission path for strings and compare it with the Ruby 2.5 and 2.6 examples in the issue. Check how YAML 1.1 parsers interpret the emitted values, then verify that sexagesimal-like strings such as MAC addresses are quoted without changing other string output.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.