From: Caleb Clausen Date: 2010-08-23T05:47:20+09:00 Subject: Re: YAML Bug - can't round-trip a hash value with leading newlines. On 8/15/10, Daniel Sheppard wrote: > YAML can't round-trip the hash: {"default"=>"\r\n Monkey \r\nX"}. > > Shouldn't yaml use the escaped string format for any string that starts with > whitespace, ie, > > yaml = "--- \ndefault: \"\\r\\n Monkey \\r\\nX\"" > p YAML.load(yaml) > => {"default"=>"\r\n Monkey \r\nX"} > > Below is a demonstration of this: > > ruby <<-EOF > hash = {"default"=>"\r\n Monkey \r\nX"} > yaml = YAML.dump(hash) > p yaml > hash2 = YAML.load(yaml) > EOF > "--- \ndefault: |-\n \r\n Monkey\r\n \r\n

Contact us

\n" > /usr/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 4, col 2: ` > X' (ArgumentError) > from /usr/lib/ruby/1.8/yaml.rb:133:in `load' > from -:4 > > ruby -v > ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux] > > > Same bug exists in the jruby implementation as well. This is bug #1311 in the ruby bug database: http://redmine.ruby-lang.org/issues/show/1311 The patch for it did finally get accepted in 1.9.2.