6.0.0-git
2018-12-15

[#6861] yaml dumper should quote values with comments
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 2008-06-09 (3841 days ago)
Due
Updated 2010-09-24 (3004 days ago)
Assigned 2009-05-02 (3514 days ago)
Resolved
Milestone
Patch No

History
2010-09-24 22:22:22 Jan Schneider Version ⇒ Git master
 
2009-05-02 02:40:56 Chuck Hagenbuch Comment #7
Taken from Chuck Hagenbuch
State ⇒ Assigned
Reply to this comment
Thanks. Mike, passing this back to you.
2009-05-02 02:37:57 apinstein (at) mac (dot) com Comment #6 Reply to this comment
I just figured out why the tests were failing for me. I have syck 
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
2009-05-02 02:05:15 Chuck Hagenbuch Comment #5
State ⇒ Resolved
Reply to this comment
Committed, thanks; I don't see any tests fail, so I'm closing this... 
if you have a failing test for the extra \n, please comment and I'll 
reopen and/or fix.
2009-04-24 06:10:24 apinstein (at) mac (dot) com Comment #4
New Attachment: yaml-comment.patch Download
Reply to this comment
I have written up a patch with some tests (attached).



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
2009-04-24 04:34:58 Chuck Hagenbuch Comment #3
State ⇒ Feedback
Reply to this comment
Well, you could supply a unit test, to help prove the patch was 
correct and not breaking anything else.
2009-04-24 01:18:26 apinstein (at) mac (dot) com Comment #2 Reply to this comment
How is this still not fixed 1 yr later? I even supplied a patch! Very 
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?
2008-06-10 00:09:31 Chuck Hagenbuch Assigned to Mike Naberezny
 
2008-06-09 07:49:45 Jan Schneider Assigned to Chuck Hagenbuch
State ⇒ Assigned
 
2008-06-09 05:12:28 apinstein (at) mac (dot) com Comment #1
Type ⇒ Bug
State ⇒ Unconfirmed
Priority ⇒ 1. Low
Summary ⇒ yaml dumper should quote values with comments
Queue ⇒ Horde Framework Packages
Milestone ⇒
Patch ⇒ No
Reply to this comment
I have run into a problem with dumping PHP arrays that contain "#" 
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.

Saved Queries