Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitc18c93b

Browse 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 | noThisfixes#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 fixI 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 parentsaebb659 +51bca66 commitc18c93b

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-
constREGEX_QUOTED_STRING ='(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')';
24+
constREGEX_QUOTED_STRING ='(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';
2525

2626
privatestatic$exceptionOnInvalidType =false;
2727
privatestatic$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+
publicfunctiontestVeryLongQuotedStrings()
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)

[8]ページ先頭

©2009-2025 Movatter.jp