Skip to content

Conversation

@smalyshev
Copy link
Contributor

The patch creates new config: mbstring.regex_stack_limit, which defaults to 100000.

This is a port of #2109 to 7.3 since it has up-to-date oniguruma lib which allows to use thread-safe functions. Ideally should be also backported down to 7.1 but that requires either code change or oniguruma upgrade, so that will come later.

The patch creates new config: mbstring.regex_stack_limit, which
defaults to 100000.
return onig_search((php_mb_regex_t *)opaque, (const OnigUChar *)str,
(const OnigUChar*)str + str_len, (const OnigUChar *)str,
(const OnigUChar*)str + str_len, NULL, ONIG_OPTION_NONE) >= 0;
OnigMatchParam *mp = onig_new_match_param();
Copy link
Member

Choose a reason for hiding this comment

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

Can this be shared between multiple matches? E.g. in PCRE we only use a single global match context for everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it, and keeping a per-thread copy of this may be ok, needs to be checked in oniguruma code what it actually is. I think there could be situations though where more than one regexp is being processed at one time (e.g. regex1 calls callback, which invokes regex2) and I am not sure how sharing MatchParam will behave in this case. I'd start with the safe way and if we can optimize later it's ok.

?>
--EXPECT--
bool(false)
bool(false)
Copy link
Member

Choose a reason for hiding this comment

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

It's odd that mb_ereg() doesn't throw a warning here, while some of the other functions do. It's a preexisting problem though, but maybe something we should fix.

@remicollet
Copy link
Member

Does that raise minimal onigurama minimal supported version ?
(which is not checked, for now, in config.m4)

@smalyshev
Copy link
Contributor Author

@remicollet bundled one supports the necessary API. Not sure about the standalone one, need to check. If there's no check probably a good idea to add one.

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.

6 participants