Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c18c93b

Browse filesBrowse files
committed
bug #21279 #20411 fix Yaml parsing for very long quoted strings (RichardBradley)
This PR was merged into the 2.7 branch. Discussion ---------- #20411 fix Yaml parsing for very long quoted strings | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20411 | License | MIT | Doc PR | no This fixes #20411, a YAML string with too many backslash escapes can trigger a `PREG_BACKTRACK_LIMIT_ERROR` error in the Yaml parser. There should be no behavioural change other than the bug fix I have included a test which fails before this fix and passes after this fix. Commits ------- 51bca66 #20411 fix Yaml parsing for very long quoted strings
2 parents aebb659 + 51bca66 commit c18c93b
Copy full SHA for c18c93b

File tree

2 files changed

+11
-1
lines changed
Filter options

2 files changed

+11
-1
lines changed

‎src/Symfony/Component/Yaml/Inline.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Inline.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/InlineTest.php
+10Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.