# Paging \_why, YAML problems

**URL:** <https://rubytalk.org/t/paging-why-yaml-problems/13233>\
**Category:** ruby-talk\
**Created:** [25 August 2004 04:29 UTC](https://rubytalk.org/t/paging-why-yaml-problems/13233 "2004-08-25T04:29:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Austin\_Ziegler5](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/austin_ziegler5/32/1985_2.png) [@Austin\_Ziegler5](https://rubytalk.org/u/Austin_Ziegler5)\
**Post date:** [25 August 2004 04:29 UTC](https://rubytalk.org/t/paging-why-yaml-problems/13233/1 "2004-08-25T04:29:57Z")

</div>

\_why:

I am having a problem with Ruby 1.8.2 preview2; the problem seems to  
be YAML with a large enough file, but the file with which I've noticed  
this I can't share, and I am still investigating to ensure that it  
isn't in my own code, but I'm 99% sure at this point.

Basically, Ruwiki supports a YAML backend that simply uses YAML.dump  
and YAML.load for a nested hash:

&nbsp;&nbsp;{ 'page' =\> { 'content' =\> actual-content-data } }

I wrote a custom backend for Ruwiki because of problems with Ruby  
1.8.1. The default pages are in this format and as I was going through  
and updating some code to reflect necessary changes to support a new  
deployment mechanism (for RubyGems and RPA, as well as central server  
installations), I tested the conversion routines to be able to switch  
between the Flatfiles, Marshal, and Yaml backends. The roundtrip  
Flatfiles =\> Marshal =\> Flatfiles appears to work regardless of the  
filesize. The Flatfiles =\> Yaml =\> Flatfiles works fine for small  
files (~2k or so), but fails on my ~14k file. The majority of these  
files is the content (13,636 bytes for the large file) is the content  
saved with \n (not \r\n, explicitly so).

The problem is that the file should be:

&nbsp;&nbsp;&nbsp;section!item:\<Tab\>content...\n  
&nbsp;&nbsp;&nbsp;\<Tab\>content...\n  
&nbsp;&nbsp;&nbsp;\<Tab\>content...\n  
&nbsp;&nbsp;&nbsp;section!item:\<Tab\>content...\n

With this test program:

&nbsp;&nbsp;p1 = Ruwiki::Backend::Flatfiles.load(data) # 1  
&nbsp;&nbsp;yaml = Ruwiki::Backend::Yaml.dump(p1) # 2  
&nbsp;&nbsp;p2 = Ruwiki::Backend::Yaml.load(yaml) # 3  
&nbsp;&nbsp;ff = Ruwiki::Backend::Flatfiles.dump(p2) # 4

In step 3 (which is simply "::YAML.load(buffer)" with a rescue to  
catch ArgumentError and raise it as a custom error), with a large  
enough file, backslashes are doubled (e.g., \\WikiWord becomes  
\\\\WikiWord and \n becomes \\n), which means that the result of #4  
will be completely wrong.

If you contact me offlist, I can give you the files that exhibit this  
behaviour. I understand you introduced some changes in 1.8.2 post  
preview2, but as of the moment, that's all I have access to on  
Windows.

-austin

> **···**
>
> --  
> Austin Ziegler \* [halostatue@gmail.com](mailto:halostatue@gmail.com)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* Alternate: [austin@halostatue.ca](mailto:austin@halostatue.ca)

---

<div class="post-metadata">

**Author:** ![why\_the\_lucky\_stiff1](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@why\_the\_lucky\_stiff1](https://rubytalk.org/u/why_the_lucky_stiff1)\
**Post date:** [27 August 2004 14:44 UTC](https://rubytalk.org/t/paging-why-yaml-problems/13233/2 "2004-08-27T14:44:04Z")

</div>

Austin Ziegler wrote:

> \_why:
> 
> I am having a problem with Ruby 1.8.2 preview2; the problem seems to  
> be YAML with a large enough file, but the file with which I've noticed  
> this I can't share, and I am still investigating to ensure that it  
> isn't in my own code, but I'm 99% sure at this point.

See [ruby-talk:109990]. Folding has been rewritten since 1.8.2, so I'll need you to try with CVS. I'm also working on getting out some binary versions of Syck. (If anyone is already doing so, please reveal yourself!)

\_why
