[Tickets #6861] yaml dumper should quote values with comments

bugs at horde.org bugs at horde.org
Mon Jun 9 05:12:29 UTC 2008


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/6861
-----------------------------------------------------------------------
 Ticket             | 6861
 Created By         | apinstein at mac.com
 Summary            | yaml dumper should quote values with comments
 Queue              | Horde Framework Packages
 Version            | FRAMEWORK_3
 Type               | Bug
 State              | Unconfirmed
 Priority           | 1. Low
 Milestone          |
 Patch              |
 Owners             |
-----------------------------------------------------------------------


apinstein at mac.com (2008-06-09 01:12) wrote:

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.




More information about the bugs mailing list