Summary | yaml dumper should quote values with comments |
Queue | Horde Framework Packages |
Queue Version | Git master |
Type | Bug |
State | Assigned |
Priority | 1. Low |
Owners | mike (at) naberezny (dot) com |
Requester | apinstein (at) mac (dot) com |
Created | 06/09/2008 (6183 days ago) |
Due | |
Updated | 09/24/2010 (5346 days ago) |
Assigned | 05/02/2009 (5856 days ago) |
Resolved | |
Milestone | |
Patch | No |
Taken from Chuck Hagenbuch
State ⇒ Assigned
installed, and just realized that Horde calls syck, which outputs
different YAML than Horde/Yaml does. When I disabled syck temporarily
all of the tests pass.
FWIW, you might consider making your tests do round-trip tests like so:
$this->assertEquals($inputPhpStruct, load(dump($inputPhpStruct)))
Also you might consider an option to "disable" syck use and use this
option for the tests to ensure that testing is actually testing the
Horde/Yaml code!
Thanks for accepting the patch.
Alan
State ⇒ Resolved
if you have a failing test for the extra \n, please comment and I'll
reopen and/or fix.
New Attachment: yaml-comment.patch
I have the dumper side working, but something odd is happening on the
loading side. There is an extra \n at the end. I am not sure why....
maybe you could figure that part out.
LMK,
Alan
State ⇒ Feedback
correct and not breaking anything else.
frustrating to remember i have to work around this bug every time I
set up a new machine...
Is there anything I can do to further this?
State ⇒ Assigned
Priority ⇒ 1. Low
Type ⇒ Bug
Summary ⇒ yaml dumper should quote values with comments
Queue ⇒ Horde Framework Packages
Milestone ⇒
Patch ⇒ No
State ⇒ Unconfirmed
characters, which is a comment signifier in YAML. I have a proposed
patch:
--- /Users/alanpinstein/Dumper.php.orig 2008-06-09 01:08:54.000000000 -0400
+++ /opt/local/lib/php/Horde/Yaml/Dumper.php 2008-06-09
01:08:57.000000000 -0400
@@ -153,6 +153,11 @@
$spaces = str_repeat(' ', $indent);
+ // quote strings if necessary
+ if (strchr($value, '#')) {
+ $value = "'{$value}'";
+ }
+
if (is_int($key)) {
// It's a sequence.
$string = $spaces . '- ' . $value . "\n";
There might be more cases, and I don't know if this breaks in the case
of folded code, but it's a start for you hopefully. This is a pretty
important bug I think because it really breaks YAML dumping if you
have this character in a string, which is a common occurrence.