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

Commitfa36ce8

Browse files
committed
minor#22067 [Yaml] ParseException: pcre.backtrack_limit reached (nicolas-grekas)
This PR was merged into the 3.3-dev branch.Discussion----------[Yaml] ParseException: pcre.backtrack_limit reached| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | no| Fixed tickets | -| License | MIT| Doc PR | -while merging 3.2 into master, I noticed that `testCanParseVeryLongValue` is triggering this error on master, due to this regexp that we added for handling yaml tags. This regexp needs to be fixed so that we can merge the test case.ping@GuilhemNCommits-------f0256f1 [Yaml] Fix pcre.backtrack_limit reached
2 parents065bf48 +f0256f1 commitfa36ce8

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function parse($value, $flags = 0)
175175
$this->refs[$isRef] =end($data);
176176
}
177177
}elseif (
178-
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:![^\s]+\s+)?[^\'"\[\{!].*?) *\:(\s+(?P<value>.+?))?\s*$#u',$this->currentLine,$values)
178+
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:![^\s]++\s++)?[^\'"\[\{!].*?) *\:(\s++(?P<value>.+))?$#u',$this->currentLine,$values)
179179
&& (false ===strpos($values['key'],' #') ||in_array($values['key'][0],array('"',"'")))
180180
) {
181181
if ($context &&'sequence' ==$context) {
@@ -209,7 +209,7 @@ public function parse($value, $flags = 0)
209209
$mergeNode =true;
210210
$allowOverwrite =true;
211211
if (isset($values['value']) &&0 ===strpos($values['value'],'*')) {
212-
$refName =substr($values['value'],1);
212+
$refName =substr(rtrim($values['value']),1);
213213
if (!array_key_exists($refName,$this->refs)) {
214214
thrownewParseException(sprintf('Reference "%s" does not exist.',$refName),$this->getRealCurrentLineNb() +1,$this->currentLine);
215215
}
@@ -250,15 +250,15 @@ public function parse($value, $flags = 0)
250250
$data +=$parsed;// array union
251251
}
252252
}
253-
}elseif (isset($values['value']) &&self::preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u',$values['value'],$matches)) {
253+
}elseif (isset($values['value']) &&self::preg_match('#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u',$values['value'],$matches)) {
254254
$isRef =$matches['ref'];
255255
$values['value'] =$matches['value'];
256256
}
257257

258258
$subTag =null;
259259
if ($mergeNode) {
260260
// Merge keys
261-
}elseif (!isset($values['value']) ||'' ==trim($values['value'],'')||0 ===strpos(ltrim($values['value'],''),'#') || (null !==$subTag =$this->getLineTag(ltrim($values['value'],''),$flags))) {
261+
}elseif (!isset($values['value']) ||'' ===$values['value']||0 ===strpos($values['value'],'#') || (null !==$subTag =$this->getLineTag($values['value'],$flags))) {
262262
// hash
263263
// if next line is less indented or equal, then it means that the current value is null
264264
if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
@@ -290,7 +290,7 @@ public function parse($value, $flags = 0)
290290
}
291291
}
292292
}else {
293-
$value =$this->parseValue($values['value'],$flags,$context);
293+
$value =$this->parseValue(rtrim($values['value']),$flags,$context);
294294
// Spec: Keys MUST be unique; first one wins.
295295
// But overwriting is allowed when a merge node is used in current block.
296296
if ($allowOverwrite || !isset($data[$key])) {

‎src/Symfony/Component/Yaml/Tests/ParserTest.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,17 @@ private function loadTestsFromFixtureFiles($testsFile)
17301730

17311731
return$tests;
17321732
}
1733+
1734+
publicfunctiontestCanParseVeryLongValue()
1735+
{
1736+
$longStringWithSpaces =str_repeat('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',20000);
1737+
$trickyVal =array('x' =>$longStringWithSpaces);
1738+
1739+
$yamlString = Yaml::dump($trickyVal);
1740+
$arrayFromYaml =$this->parser->parse($yamlString);
1741+
1742+
$this->assertEquals($trickyVal,$arrayFromYaml);
1743+
}
17331744
}
17341745

17351746
class B

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp