Bug in the YAML library: #dump fails for certain multi-line strings

Discussion in 'Ruby' started by John Trupiano, Sep 5, 2008.

  1. Hey guys,

    I stumbled across what is a bug in the YAML library. It does not
    properly encode certain multi-line strings. Fire up irb, and try the
    following:

    >> require 'yaml'

    => true
    >> s3 = "\n Do I work?\nNo indent"

    => "\n Do I work?\nNo indent"
    >> YAML.load(YAML.dump(s3))

    ArgumentError: syntax error on line 3, col 0: `No indent'
    from /opt/ruby-enterprise-1.8.6-20080810/lib/ruby/1.8/yaml.rb:133:in
    `load'
    from /opt/ruby-enterprise-1.8.6-20080810/lib/ruby/1.8/yaml.rb:133:in
    `load'
    from (irb):3

    I've confirmed it's broken in both 1.8.6.p111, and REE 1.8.6.p287.

    I wrote up a pretty thorough exploration of this bug in a blog post
    describing the problem and offering a (sub-optimal) patch:
    http://blog.smartlogicsolutions.com...amldump-for-multi-line-strings-stringto_yaml/

    Is this the right list to discuss this?

    -John
     
    John Trupiano, Sep 5, 2008
    #1
    1. Advertising

  2. Re: Bug in the YAML library: #dump fails for certain multi-line strings

    Just upping this because I think it's particularly important. Is
    there a better venue to discuss this? Just curious where the
    interested parties (read: the ruby YAML library maintainers) are.....

    -John

    On Sep 5, 6:17=A0am, John Trupiano <> wrote:
    > Hey guys,
    >
    > I stumbled across what is a bug in the YAML library. =A0It does not
    > properly encode certain multi-line strings. =A0Fire up irb, and try the
    > following:
    >
    > >> require 'yaml'

    > =3D> true
    > >> s3 =3D "\n =A0Do I work?\nNo indent"

    >
    > =3D> "\n =A0Do I work?\nNo indent">> YAML.load(YAML.dump(s3))
    >
    > ArgumentError: syntax error on line 3, col 0: `No indent'
    > =A0 =A0 =A0 =A0 from /opt/ruby-enterprise-1.8.6-20080810/lib/ruby/1.8/yam=

    l.rb:133:in
    > `load'
    > =A0 =A0 =A0 =A0 from /opt/ruby-enterprise-1.8.6-20080810/lib/ruby/1.8/yam=

    l.rb:133:in
    > `load'
    > =A0 =A0 =A0 =A0 from (irb):3
    >
    > I've confirmed it's broken in both 1.8.6.p111, and REE 1.8.6.p287.
    >
    > I wrote up a pretty thorough exploration of this bug in a blog post
    > describing the problem and offering a (sub-optimal) patch:http://blog.sma=

    rtlogicsolutions.com/2008/09/04/ruby-patch-to-fix-brok...
    >
    > Is this the right list to discuss this?
    >
    > -John
     
    John Trupiano, Sep 5, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. halfdog
    Replies:
    12
    Views:
    12,467
  2. Paul Battley

    YAML.dump/YAML.load bug

    Paul Battley, Aug 3, 2005, in forum: Ruby
    Replies:
    0
    Views:
    182
    Paul Battley
    Aug 3, 2005
  3. Tom Payne
    Replies:
    3
    Views:
    186
    Johannes Friestad
    Dec 14, 2005
  4. Jonathan Gold
    Replies:
    0
    Views:
    141
    Jonathan Gold
    May 19, 2009
  5. Rud1ger Sch1erz
    Replies:
    1
    Views:
    257
Loading...

Share This Page