Bug #73948 [Asn->Csd]: Preg_match_all should return NULLs on trailing optional capture groups.
| From: | nikic@php.net | Date: | Thu, 21 Mar 2019 09:23:19 +0000 |
| Subject: | Bug #73948 [Asn->Csd]: Preg_match_all should return NULLs on trailing optional capture groups. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220111@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73948&edit=1
ID: 73948
Updated by: nikic@php.net
Reported by: tomasyorke at hotmail dot com
Summary: Preg_match_all should return NULLs on trailing
optional capture groups.
-Status: Assigned
+Status: Closed
Type: Bug
Package: PCRE related
Operating System: Windows 7
PHP Version: 7.0.14
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6311581ac64372164de7ba24f086eb3b0b91eabb
Log: Fix bug #73948
Previous Comments:
------------------------------------------------------------------------
[2019-03-19 14:39:02] nikic@php.net
> But I found a nearly identical bug with the PREG_OFFSET_CAPTURE flag.
Fixed this issue with https://github.com/php/php-src/commit/f53e7394eb61085c09928b47f84123bd90b64dfb
on the PHP 7.4 branch.
------------------------------------------------------------------------
[2019-03-19 13:04:46] nikic@php.net
PR for PHP 7.4: https://github.com/php/php-src/pull/3964
------------------------------------------------------------------------
[2018-06-09 22:51:16] php at tecnopolis dot ca
For those stuck on older PHP's, I'm wondering if the following is sufficient to work
around this bug?
$pattern.='(.??)';
preg_match($pattern,$haystack,$matches);
array_pop($matches);
I can't yet find any instance where the fairly innocuous (.??) could possibly cause a problem,
it should match in all cases, when there's chars left or not, and being non-greedy will not eat
earlier matches' chars.
------------------------------------------------------------------------
[2018-04-14 15:08:34] nikic@php.net
@requinix: That's impossible for BC reasons. I agree with @cmb that this should only be done
for PREG_UNMATCHED_AS_NULL.
------------------------------------------------------------------------
[2018-04-14 14:47:18] requinix@php.net
The filling should happen with or without PREG_UNMATCHED_AS_NULL. What it should control whether the
filler is NULLs or empty strings.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=73948
--
Edit this bug report at https://bugs.php.net/bug.php?id=73948&edit=1