Ticket #30 (new defect)
Opened 17 months ago
Inline sequence definitions require spaces to be processed properly
| Reported by: | josb | Owned by: | somebody |
|---|---|---|---|
| Priority: | minor | Milestone: | milestone1 |
| Component: | component1 | Version: | |
| Keywords: | Cc: | jos@… |
Description
Although I didn't see anything offhand in the YAML spec suggesting they are mandatory, the example below shows that omitting the spaces after the commas causes Syck to misinterpret the sequence, joining the elements into a single element instead:
$ ruby -v
ruby 1.8.5 (2006-08-25) [i386-linux]
$ irb
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> YAML::VERSION
=> "0.60"
irb(main):003:0> yaml =<<EOY
irb(main):004:0" ---
irb(main):005:0" seq: [1, 2, 3]
irb(main):006:0" EOY
=> "--- \nseq: [1, 2, 3]\n"
irb(main):007:0> YAML.load(yaml)
=> {"seq"=>[1, 2, 3]}
irb(main):008:0> yaml =<<EOY
irb(main):009:0" ---
irb(main):010:0" seq: [1,2,3]
irb(main):011:0" EOY
=> "--- \nseq: [1,2,3]\n"
irb(main):012:0> YAML.load(yaml)
=> {"seq"=>[123]}
irb(main):013:0>
When the [1,2,3] is replaced with ['a','b','c'], YAML.load raises an ArgumentError:
$ irb
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> yaml =<<EOY
irb(main):003:0" ---
irb(main):004:0" seq: ['a','b','c']
irb(main):005:0" EOY
=> "--- \nseq: ['a','b','c']\n"
irb(main):006:0> YAML.load(yaml)
ArgumentError: syntax error on line 1, col 17: `'
from /usr/lib/ruby/1.8/yaml.rb:133:in `load'
from /usr/lib/ruby/1.8/yaml.rb:133:in `load'
from (irb):5
irb(main):007:0>
When spaces are added (as in the first example), things work as expected.
Note: See
TracTickets for help on using
tickets.