Author: fabien
Date: 2010-03-12 15:56:16 +0100 (Fri, 12 Mar 2010)
New Revision: 28508

Modified:
   components/yaml/branches/1.0/lib/sfYamlParser.php
   components/yaml/branches/1.0/test/fixtures/sfTests.yml
   components/yaml/branches/1.0/test/sfYamlDumperTest.php
   components/yaml/branches/1.0/test/sfYamlParserTest.php
   components/yaml/trunk/lib/sfYamlParser.php
   components/yaml/trunk/test/fixtures/sfTests.yml
   components/yaml/trunk/test/sfYamlDumperTest.php
   components/yaml/trunk/test/sfYamlParserTest.php
Log:
[YAML] fixed parsing of folded scalars when a # sign starts a line (closes 
#8398)

Modified: components/yaml/branches/1.0/lib/sfYamlParser.php
===================================================================
--- components/yaml/branches/1.0/lib/sfYamlParser.php   2010-03-12 14:40:26 UTC 
(rev 28507)
+++ components/yaml/branches/1.0/lib/sfYamlParser.php   2010-03-12 14:56:16 UTC 
(rev 28508)
@@ -290,12 +290,9 @@
 
     while ($this->moveToNextLine())
     {
-      if ($this->isCurrentLineEmpty())
+      if ($this->isCurrentLineBlank())
       {
-        if ($this->isCurrentLineBlank())
-        {
-          $data[] = substr($this->currentLine, $newIndent);
-        }
+        $data[] = substr($this->currentLine, $newIndent);
 
         continue;
       }

Modified: components/yaml/branches/1.0/test/fixtures/sfTests.yml
===================================================================
--- components/yaml/branches/1.0/test/fixtures/sfTests.yml      2010-03-12 
14:40:26 UTC (rev 28507)
+++ components/yaml/branches/1.0/test/fixtures/sfTests.yml      2010-03-12 
14:56:16 UTC (rev 28508)
@@ -137,3 +137,31 @@
     0123
 php: |
   array('foo' => "0123\n")
+---
+test: Comments in folded scalars
+brief: Comments in folded scalars should be kept as is
+yaml: |
+  # comment
+  foo: |
+    # comment
+    bar
+  bar:
+    # comment
+    foo: bar # comment
+    bar: |
+      # comment
+      foo
+    foobar:
+      foo: |
+        # comment
+        bar
+  # comment
+php: |
+  array(
+    'foo' => "# comment\nbar\n",
+    'bar' => array(
+      'foo' => 'bar',
+      'bar' => "# comment\nfoo\n",
+      'foobar' => array('foo' => "# comment\nbar\n")
+    )
+  )

Modified: components/yaml/branches/1.0/test/sfYamlDumperTest.php
===================================================================
--- components/yaml/branches/1.0/test/sfYamlDumperTest.php      2010-03-12 
14:40:26 UTC (rev 28507)
+++ components/yaml/branches/1.0/test/sfYamlDumperTest.php      2010-03-12 
14:56:16 UTC (rev 28508)
@@ -15,7 +15,7 @@
 
 sfYaml::setSpecVersion('1.1');
 
-$t = new lime_test(149);
+$t = new lime_test(150);
 
 $parser = new sfYamlParser();
 $dumper = new sfYamlDumper();

Modified: components/yaml/branches/1.0/test/sfYamlParserTest.php
===================================================================
--- components/yaml/branches/1.0/test/sfYamlParserTest.php      2010-03-12 
14:40:26 UTC (rev 28507)
+++ components/yaml/branches/1.0/test/sfYamlParserTest.php      2010-03-12 
14:56:16 UTC (rev 28508)
@@ -14,7 +14,7 @@
 
 sfYaml::setSpecVersion('1.1');
 
-$t = new lime_test(149);
+$t = new lime_test(150);
 
 $parser = new sfYamlParser();
 

Modified: components/yaml/trunk/lib/sfYamlParser.php
===================================================================
--- components/yaml/trunk/lib/sfYamlParser.php  2010-03-12 14:40:26 UTC (rev 
28507)
+++ components/yaml/trunk/lib/sfYamlParser.php  2010-03-12 14:56:16 UTC (rev 
28508)
@@ -307,12 +307,9 @@
 
     while ($this->moveToNextLine())
     {
-      if ($this->isCurrentLineEmpty())
+      if ($this->isCurrentLineBlank())
       {
-        if ($this->isCurrentLineBlank())
-        {
-          $data[] = substr($this->currentLine, $newIndent);
-        }
+        $data[] = substr($this->currentLine, $newIndent);
 
         continue;
       }

Modified: components/yaml/trunk/test/fixtures/sfTests.yml
===================================================================
--- components/yaml/trunk/test/fixtures/sfTests.yml     2010-03-12 14:40:26 UTC 
(rev 28507)
+++ components/yaml/trunk/test/fixtures/sfTests.yml     2010-03-12 14:56:16 UTC 
(rev 28508)
@@ -143,3 +143,31 @@
     0123
 php: |
   array('foo' => "0123\n")
+---
+test: Comments in folded scalars
+brief: Comments in folded scalars should be kept as is
+yaml: |
+  # comment
+  foo: |
+    # comment
+    bar
+  bar:
+    # comment
+    foo: bar # comment
+    bar: |
+      # comment
+      foo
+    foobar:
+      foo: |
+        # comment
+        bar
+  # comment
+php: |
+  array(
+    'foo' => "# comment\nbar\n",
+    'bar' => array(
+      'foo' => 'bar',
+      'bar' => "# comment\nfoo\n",
+      'foobar' => array('foo' => "# comment\nbar\n")
+    )
+  )

Modified: components/yaml/trunk/test/sfYamlDumperTest.php
===================================================================
--- components/yaml/trunk/test/sfYamlDumperTest.php     2010-03-12 14:40:26 UTC 
(rev 28507)
+++ components/yaml/trunk/test/sfYamlDumperTest.php     2010-03-12 14:56:16 UTC 
(rev 28508)
@@ -15,7 +15,7 @@
 
 sfYaml::setSpecVersion('1.1');
 
-$t = new lime_test(150);
+$t = new lime_test(151);
 
 $parser = new sfYamlParser();
 $dumper = new sfYamlDumper();

Modified: components/yaml/trunk/test/sfYamlParserTest.php
===================================================================
--- components/yaml/trunk/test/sfYamlParserTest.php     2010-03-12 14:40:26 UTC 
(rev 28507)
+++ components/yaml/trunk/test/sfYamlParserTest.php     2010-03-12 14:56:16 UTC 
(rev 28508)
@@ -14,7 +14,7 @@
 
 sfYaml::setSpecVersion('1.1');
 
-$t = new lime_test(150);
+$t = new lime_test(151);
 
 $parser = new sfYamlParser();
 

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to