Bug #80866 [Opn->Csd]: preg_split ignores limit flag when pattern with \K has 0-width fullstring match
| From: | nikic@php.net | Date: | Mon, 15 Mar 2021 13:48:20 +0000 |
| Subject: | Bug #80866 [Opn->Csd]: preg_split ignores limit flag when pattern with \K has 0-width fullstring match | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232730@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80866&edit=1
ID: 80866
Updated by: nikic@php.net
Reported by: mickmackusa at mickmack dot usa
Summary: preg_split ignores limit flag when pattern with \K
has 0-width fullstring match
-Status: Open
+Status: Closed
Type: Bug
Package: PCRE related
PHP Version: 7.3.27
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of tekiela246@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=282355efd5d53ba180d30794737c33898031104e
Log: Fix bug #80866
Previous Comments:
------------------------------------------------------------------------
[2021-03-15 12:23:42] dharman@php.net
The following pull request has been associated:
Patch Name: Fix bug 80866
On GitHub: https://github.com/php/php-src/pull/6774
Patch: https://github.com/php/php-src/pull/6774.patch
------------------------------------------------------------------------
[2021-03-15 02:02:50] mickmackusa at mickmack dot usa
Description:
------------
preg_split() does not respect the limit parameter when \K is used to produce a zero-width fullstring
delimiter. https://3v4l.org/kQHQZ This bug seems to be present
since PHP7.3. Other preg_split() calls using zero-width-match-producing regular expressions do not
suffer the same bug.
https://3v4l.org/3KP1T
Test script:
---------------
var_export(preg_split('~.{3}\K~', 'abcdefghijklm', 3));
Expected result:
----------------
array (
0 => 'abc',
1 => 'def',
2 => 'ghijklm',
)
Actual result:
--------------
array (
0 => 'abc',
1 => 'def',
2 => 'ghi',
3 => 'jkl',
4 => 'm',
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80866&edit=1