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

Use preg_split instead of preg_match with quantifiers in safe_substr. #123

Merged
merged 1 commit into from
Oct 12, 2017

Conversation

gitlost
Copy link
Contributor

@gitlost gitlost commented Oct 12, 2017

Fixes wp-cli/db-command#54

Uses preg_split() instead of preg_match() with quantifiers in safe_substr() to avoid 65535 limit on quantifiers (regexp.reference.repetition), encountered for large strings.

Also normalizes the $start arg so its behaviour is the same no matter which substr method gets used.

Also checks that mb_substr() is available before using it in _safe_substr_eaw().

The following was noticed in testing and is unrelated so can do in a separate PR to reduce churn if desirable:

Also adds check that $encoding doesn't evaluate to false before passing it to mbstring functions as they can fail otherwise (seems to be system dependent).

@gitlost gitlost added the bug label Oct 12, 2017
@gitlost gitlost requested a review from a team October 12, 2017 19:55
Copy link
Member

@miya0001 miya0001 left a comment

Choose a reason for hiding this comment

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

Oh, great...
Looks good to me, because there are no removed tests and some tests are added. 😊

@gitlost gitlost added this to the 0.11.8 milestone Oct 12, 2017
@danielbachhuber danielbachhuber merged commit 363c753 into master Oct 12, 2017
@danielbachhuber danielbachhuber deleted the use_preg_split_in_safe_substr branch October 12, 2017 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants