From: noreply@... Date: 2007-03-21T14:05:06+09:00 Subject: [ ruby-Bugs-8026 ] YAML fails to parse its own input Bugs item #8026, was opened at 2007-01-20 10:44 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=1698&aid=8026&group_id=426 Category: Standard Library Group: 1.9.x Status: Open Resolution: None Priority: 3 Submitted By: Vincent Fourmond (fourmond) Assigned to: Nobody (None) Summary: YAML fails to parse its own input Initial Comment: In certain cases, when strings contains weird amount of whitespace, YAML fails to parse it's own output. The attached file, when run (1.8.5 and current trunk), produces the following error: # It seems excessive amount of whitespace confuses the parser. Is there another way to output long strings in a safe way ? The attached file also contains two really close examples that don't trigger the syntax error. ---------------------------------------------------------------------- Comment By: Jason May (jmay) Date: 2007-03-20 22:05 Message: This bug also appears on macosx. Here's an even shorter example: YAML.load("\n foo\nbar".to_yaml) It seems to break when there is a leading newline-space and another newline further on. ---------------------------------------------------------------------- Comment By: Vincent Fourmond (fourmond) Date: 2007-01-24 23:47 Message: Thanks for the pointer, I got around the problem by simply removing blank lines in strings, which was acceptable in my case. ---------------------------------------------------------------------- Comment By: Akira FUNAI (afunai) Date: 2007-01-21 00:42 Message: > Is there another way to output long strings in a safe way ? Try "Syck compatible" mode of Ya2YAML (http://rubyforge.org/projects/ya2yaml/). --- require 'yaml' require 'rubygems' require 'ya2yaml' a = < true) begin YAML.load(s) rescue Exception => e p e end --- p.s. The second example in the attached file don't trigger the error, but have a roundtrip problem (a != YAML.load(a.to_yaml)). (ruby 1.8.5) ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=1698&aid=8026&group_id=426