Critical pcre-8.41-r0 regex bug with php-7.*
There appears to be a serious issue with pcre 8.41-r0 that is affecting all regular expressions in php7 which contain expressions with brackets.
Please note that I don’t run pre-packaged versions of PHP, all php versions are self-compiled on Alpine. I have multiple docker containers running different versions of PHP, however any alpine container that is newly created (latest alpine 3.6 code-base + with a fresh compile of any PHP7), or any existing working container that is upgraded (apm upgrade) to pcre 8.41-r0 has this serious bug. PHP 5.6.* does not seem affected.
I have tested with multiple versions pf PHP7 (7.1.7, 7.1.8, 7.1.9), all experience the exact same issue: Any regex (eg: preg_match) that contain expressions with brackets fail (empty results).
Example:
preg_match('/^([0-9]+)$/', '12345', $matches);
print_r($matches);
Expected output (as with any prior version of pcre):
Array
(
[0] => 12345
[1] => 12345
)
Output with pcre-8.41-r0:
Array
(
)
I cannot work out exactly what release of pcre introduced the issue as Alpine doesn’t have a repository of previous versions of a package (for a particular alpine release, ie: 3.6), but I know that pcre-8.40-r2 and older works as expected in all environments.
(from redmine: issue id 7781, created on 2017-09-01, closed on 2018-09-11)