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

[Yaml] ParseException: pcre.backtrack_limit reached#22067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromnicolas-grekas:yaml-long-string
Mar 22, 2017

Conversation

@nicolas-grekas
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?no
Fixed tickets-
LicenseMIT
Doc PR-

while merging 3.2 into master, I noticed thattestCanParseVeryLongValue 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@GuilhemN

}
}elseif (
// this regexp is backtracking-heavy and makes the parser fail on long strings
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:![^\s]+\s+)?[^\'"\[\{!].*?) *\:(\s+(?P<value>.+?))?\s*$#u',$this->currentLine,$values)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Most quantifiers in this regex could probably become possessive ones actually, to remove backtracking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Changing the regex toself::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{!].*?) *+\:(\s++(?P<value>.+?))?\s*+$#u', $this->currentLine, $values) doesn't seem to be enough.
Do you see another possible improvement?

@nicolas-grekas
Copy link
MemberAuthor

Regexp fixed. PR ready.

}
}elseif (
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:![^\s]+\s+)?[^\'"\[\{!].*?) *\:(\s+(?P<value>.+?))?\s*$#u',$this->currentLine,$values)
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:![^\s]++\s++)?[^\'"\[\{!].*?) *\:(\s++(?P<value>.+))?$#u',$this->currentLine,$values)
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@GuilhemN the issue was the last part of the regexp, the related to the last\s* and the ungreedy quantifier just before.

GuilhemN reacted with thumbs up emoji
Copy link
Member

@stofstof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍

$allowOverwrite =true;
if (isset($values['value']) &&0 ===strpos($values['value'],'*')) {
$refName =substr($values['value'],1);
$refName =substr(rtrim($values['value']),1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

rtrim($values['value'], ' ')? tabs should not be trimmed.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

weren't they previously already, with this\s+$ tail?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Indeed, it's legit then 👍

@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commitf0256f1 intosymfony:masterMar 22, 2017
fabpot added a commit that referenced this pull requestMar 22, 2017
…olas-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
@nicolas-grekasnicolas-grekas deleted the yaml-long-string branchMarch 22, 2017 20:24
@lcobucci
Copy link
Contributor

@nicolas-grekas@fabpot@stof this change breaks the parser when you a have a trailing space after the colon. Doctrine ORM test suite has it and it started to break after this PR got merged (we use"symfony/yaml": "~2.3|~3.0" onrequire-dev).

I've discovered that by adding the following to theParserTest.php:

publicfunctiontestCanParseContentWithTrailingSpaces()    {$yaml =<<<YAMLitems:  foo: barYAML;$expected = ['items' => ['foo' =>'bar'],        ];$this->assertEquals($expected,$this->parser->parse($yaml));    }

I'm not sure if having a trailing space is valid according to the YAML syntax rules, however it was working before.

@nicolas-grekas
Copy link
MemberAuthor

Valid report, please open an issue.

lcobucci reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof approved these changes

+1 more reviewer

@GuilhemNGuilhemNGuilhemN left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

6 participants

@nicolas-grekas@fabpot@lcobucci@stof@GuilhemN@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp