YAML.dump/YAML.load bug

P

Paul Battley

I have identified what seems to be a bug in the current Ruby
implementation of YAML.

YAML.dump handles binary data without a problem; it is dumped as
expected. However, when YAML.load is used to read the same data back
in, it *sometimes* fails. I analysed the exact failure behaviour by
serialising and deserialising random data, then comparing all the
failed data until I had pinpointed the exact causes.

These are the criteria for failure:

* A string is used as a hash key.
* The string contains a byte 0x00.
* The string contains a byte 0x0a in a non-final position.

When all three criteria are met, YAML.load cannot successfully read
YAML.dump's output.

I've made a set of test cases to demonstrate the problem:
http://po-ru.com/files/breakyaml.rb

In my tests, it fails on 1.8.2 and the current stable snapshot, on
both Linux/686 and OS X/PPC.

Paul Battley.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top