Skip to content

Commit 51bca66

Browse files
symfony#20411 fix Yaml parsing for very long quoted strings
1 parent aebb659 commit 51bca66

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class Inline
2323
{
24-
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')';
24+
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';
2525

2626
private static $exceptionOnInvalidType = false;
2727
private static $objectSupport = false;

src/Symfony/Component/Yaml/Tests/InlineTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,14 @@ public function testNotSupportedMissingValue()
410410
{
411411
Inline::parse('{this, is not, supported}');
412412
}
413+
414+
public function testVeryLongQuotedStrings()
415+
{
416+
$longStringWithQuotes = str_repeat("x\r\n\\\"x\"x", 1000);
417+
418+
$yamlString = Inline::dump(array('longStringWithQuotes' => $longStringWithQuotes));
419+
$arrayFromYaml = Inline::parse($yamlString);
420+
421+
$this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
422+
}
413423
}

0 commit comments

Comments
 (0)