Skip to content
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

Stops ProcessBase::removeNonJsonJunk returning NULL when valid JSON i… #35

Merged
merged 2 commits into from
Apr 2, 2019

Conversation

edwinknl
Copy link
Contributor

…s passed in

Overview

This pull request fixes issue #34

Q A
Bug fix? yes
New feature? no
Has tests? no
BC breaks? no
Deprecations? no

Summary

prevent passing strings into preg_replace that would cause the backtrack limit to be exceeded.

Description

See issue #34

@greg-1-anderson
Copy link
Member

The php manual says:

Note:
It is usually not possible to match more than pcre.backtrack_limit characters in ungreedy mode.

The default mode is greedy, so I'm not sure why we'd have this limitation. Perhaps it has something to do with matching characters at the end of the string.

I'm not fond of the amount of work needed here just to get the regex to work. Perhaps a simpler solution that just used strrpos and a substring would also work?

@legolasbo
Copy link

The goal of the regexes is to remove any characters before the first { and any characters after the last }. So I recon we could definitely use strpos + substring for this. Great idea!

@edwinknl edwinknl force-pushed the master branch 2 times, most recently from d68967c to 1ccda71 Compare March 25, 2019 14:59
Minimize rework and use strrpos  as suggeted by greg-1-anderson.
@greg-1-anderson
Copy link
Member

Lost track of this PR. Looks exactly right. Thanks for the improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants