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

**URL:** <https://www.ruby-forum.com/t/bug-in-the-yaml-library-dump-fails-for-certain-multi-line-strings/147783>\
**Category:** Ruby\
**Created:** [September 5, 2008, 12:23pm UTC](https://www.ruby-forum.com/t/bug-in-the-yaml-library-dump-fails-for-certain-multi-line-strings/147783 "2008-09-05T12:23:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [September 5, 2008, 12:23pm UTC](https://www.ruby-forum.com/t/bug-in-the-yaml-library-dump-fails-for-certain-multi-line-strings/147783/1 "2008-09-05T12:23:19Z")

</div>

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/2008/09/04/ruby-patch-to-fix-broken-yamldump-for-multi-line-strings-stringto\_yaml/](http://blog.smartlogicsolutions.com/2008/09/04/ruby-patch-to-fix-broken-yamldump-for-multi-line-strings-stringto_yaml/)

Is this the right list to discuss this?

-John

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [September 5, 2008, 7:08pm UTC](https://www.ruby-forum.com/t/bug-in-the-yaml-library-dump-fails-for-certain-multi-line-strings/147783/2 "2008-09-05T19:08:59Z")

</div>

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
