Project

General

Profile

Actions

Bug #1311

closed

YAML::dump creates strings YAML::load cannot parse

Added by rampion (Noah Easterly) over 15 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.6 (2007-03-13 patchlevel 0) [powerpc-darwin8.9.0], ruby 1.8.7 (2008-05-31 patchlevel 0) [i686-darwin9.3.0]
Backport:
[ruby-core:23006]

Description

=begin
This case seems to occur whenever

  • the string begins with a newline, and
  • the last line doesn't end in whitespace (except, perhaps, newlines), and
  • the second line (after the initial whitespace) begins with more whitespace than some later line

Here are a couple example strings:

  • "\n a\nb"
  • "\n a\n b\nc"
  • "\n a\n b"

YAML::load throws an ArgumentError with a syntax error on the line that begins with less leading
whitespace.

  • YAML.load YAML.dump("\n a\nb") #=> ArgumentError: syntax error on line 3, col 0: `b'
  • YAML.load YAML.dump("\n a\n b\nc") #=> ArgumentError: syntax error on line 4, col 0: `c'
  • YAML.load YAML.dump("\n a\n b") #=> ArgumentError: syntax error on line 3, col 1: ` b'

This has been observed in ruby-1.8.6p0 and ruby-1.8.7p0.

Here is another observation of this same bug: http://blog.smartlogicsolutions.com/2008/09/04/ruby-patch-to-fix-broken-yamldump-for-multi-line-strings-stringto_yaml/
=end


Files

syck_scan_scalar.patch (497 Bytes) syck_scan_scalar.patch daz (Dave B), 03/25/2009 09:54 PM
test_yaml.patch (1.32 KB) test_yaml.patch all tests pass daz (Dave B), 03/25/2009 09:54 PM
test_yaml2.patch (1.42 KB) test_yaml2.patch coatl (caleb clausen), 09/30/2009 02:23 AM
syck_scan_scalar2.patch (540 Bytes) syck_scan_scalar2.patch coatl (caleb clausen), 09/30/2009 02:23 AM
yaml-error.txt (1.43 KB) yaml-error.txt weppos (Simone Carletti), 03/19/2010 09:02 PM

Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #2767: YAML bugClosed02/20/2010Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0