-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[yaml] Inline::parseQuotedScalar() causes stack overflow in Windows is field contains a lot of double quotes #14722
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
We should try to use possessive quantifiers if it is possible. |
@mahagr can you provide the file which triggered the issue for you to help reproducing the issue ? |
I'm just trying to debug it myself, possessive quantifiers seem to need 3-5 times as many steps to get the result. I'm using the following html code as my example:
(remember to put the value into some variable, I just gave you the contents) But it fails on even smaller data. |
I think the best solution would be to internally convert " and ' into something else before using a simpler regexp. Not sure what the side effects of that would be, but it might be the easiest solution to both speed it up and use less stack. |
As crashing your Apache may be bad idea (and issue only affects Windows), you may try to add this to your php.ini to get it to fail:
|
After some testing, it looks like possessive quantifiers fixes the issue:
|
I'm taking that back, there seem to be some issues with that one... Second expression is wrong.. |
Reverted the second part back to what it was and this seems to work so far:
Not sure if single quoted one has the same issues or if its fine. |
Looks like that even that doesn't really fix the issue. Bah.. |
Any ideas on how to fix this one? One way would be to replace first all instances of /" and then do simpler regexp. |
Maybe using a |
Interesting... Even if StringReader is slower than regexps in general, it would be much faster in case of parsing html inside the yaml string as it wouldn't use megabytes of memory trying to parse escaped " |
This should be fixed by #20411 now. |
The following regexp uses a lot of recursion every time the content has a lot of double quotes:
Basically it is causing a crash in windows due to stack overflow on large inputs (~20k of escaped html in the field).
The text was updated successfully, but these errors were encountered: