YAML.dump/YAML.load bug

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.