-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
PREG_BACKTRACK_LIMIT_ERROR in Yaml parser #20411
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
using possessive quantifiers should indeed be done. Regarding your point 2, this would involve distinguishing |
…ardBradley) 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
👍 Thanks for fixing this one, its a big one. It should also improve yaml parsing performance (on affected input) by a great deal. |
You're welcome. Do you know when I can expect a 3.2 based release which will include this fix? |
I'm waiting for the release as much as you do :) |
Since the last patch releases have just been released two days ago you will have to wait for about four weeks for the next releases. |
* 2.7: fixed typo Revert "fixed typo" fixed typo fixed CS Avoid setting request attributes from signature arguments in AnnotationClassLoader [DependencyInjection] Add some missing typehints in YamlFileLoader [DependencyInjection] minor: Fix a DocBlock [HttpKernel] Give higher priority to adding request formats [FrameworkBundle] Fix third level headers for MarkdownDescriptor [TwigBundle] do not lose already set method calls #20411 fix Yaml parsing for very long quoted strings CS: apply is_null DX: remove invalid inheritdoc bumped Symfony version to 2.7.24 updated VERSION for 2.7.23 update CONTRIBUTORS for 2.7.23 updated CHANGELOG for 2.7.23 [FrameworkBundle] Skip test if xdebug.file_link_format is defined.
* 2.8: (26 commits) fixed CS fixed CS fixed CS fixer config fixed typo Revert "fixed typo" fixed typo fixed CS Avoid setting request attributes from signature arguments in AnnotationClassLoader [DependencyInjection] Add some missing typehints in YamlFileLoader [DependencyInjection] minor: Fix a DocBlock [HttpKernel] Give higher priority to adding request formats [PropertyInfo] Don't try to access a property thru a static method [PropertyInfo] Exclude static methods form properties guessing [FrameworkBundle] Fix third level headers for MarkdownDescriptor [TwigBundle] do not lose already set method calls #20411 fix Yaml parsing for very long quoted strings CS: apply is_null DX: remove invalid inheritdoc bumped Symfony version to 2.8.17 updated VERSION for 2.8.16 ...
* 3.1: (31 commits) fixed CS fixed CS fixed CS fixer config fixed typo Revert "fixed typo" fixed typo fixed CS Avoid setting request attributes from signature arguments in AnnotationClassLoader [DependencyInjection] Add some missing typehints in YamlFileLoader [DependencyInjection] minor: Fix a DocBlock [HttpKernel] Give higher priority to adding request formats [PropertyInfo] Don't try to access a property thru a static method [PropertyInfo] Exclude static methods form properties guessing [FrameworkBundle] Fix third level headers for MarkdownDescriptor [Ldap] Using Ldap stored username instead of form submitted one [Ldap] load users with the good username case [DoctrineBridge] Fixed invalid unique value as composite key [Doctrine Bridge] fix UniqueEntityValidator for composite object primary keys [TwigBundle] do not lose already set method calls #20411 fix Yaml parsing for very long quoted strings ...
…ardBradley) This PR was squashed before being merged into the 2.7 branch (closes #21523). 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 is a second fix for the issue discussed in #20411. My first PR (#21279) didn't fix the bug in all cases, sorry. If a YAML string has too many spaces in the value, it 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. I have also added checks that detect other PCRE internal errors and throw a more descriptive exception. Before this patch, the YAML engine would often give incorrect results, rather than throwing, on a PCRE `PREG_BACKTRACK_LIMIT_ERROR` error. Commits ------- c9a1c09 #20411 fix Yaml parsing for very long quoted strings
* 2.7: #20411 fix Yaml parsing for very long quoted strings [Doctrine Bridge] fix priority for doctrine event listeners Use PHP functions as array_map callbacks when possible [Validator] revert wrong Phpdoc change Use proper line endings
* 2.8: [DI] Fix PhpDumper generated doc block #20411 fix Yaml parsing for very long quoted strings [Doctrine Bridge] fix priority for doctrine event listeners Use PHP functions as array_map callbacks when possible [Validator] revert wrong Phpdoc change Use proper line endings
* 3.2: [Yaml] CS [DI] Fix PhpDumper generated doc block #20411 fix Yaml parsing for very long quoted strings [Workflow] add Phpdoc for better IDE support fix package name in conflict rule improve message when workflows are missing [Doctrine Bridge] fix priority for doctrine event listeners Use PHP functions as array_map callbacks when possible [Validator] revert wrong Phpdoc change Use proper line endings
A YAML string with too many backslash escapes can trigger a
PREG_BACKTRACK_LIMIT_ERROR
error in the Yaml parser.Steps to reproduce:
Run the following unit test:
Observed behaviour
This test will pass if you reduce the "1000" constant to "100", and fail as-is.
The reported exception is:
The relevant source is here:
Expected behaviour
The test should pass, i.e. the YAML should be parseable, since it fits in memory and is well formed.
The exception thrown by Symfony if the
preg_match
fails due toPREG_BACKTRACK_LIMIT_ERROR
should indicate that the op failed due to resource exhaustion and not incorrectly blame invalid YAML.Suggested fix
I suspect that changing the
REGEX_QUOTED_STRING
regex to use possessive qualifiers will probably fix bug 1 above without otherwise changing the YAML parser's behaviour.Fixing bug 2 above needs a call to
preg_last_error()
after each "preg_match
" call in Symfony code, which will be tedious.The text was updated successfully, but these errors were encountered: