Bug #80865 [NEW]: preg_split ignores limit flag when pattern with \K has 0-width fullstring match
| From: | mickmackusa at gmail dot com | Date: | Mon, 15 Mar 2021 01:15:54 +0000 |
| Subject: | Bug #80865 [NEW]: preg_split ignores limit flag when pattern with \K has 0-width fullstring match | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-232708@lists.php.net to get a copy of this message | ||
From: mickmackusa at gmail dot com
Operating system:
PHP version: 7.3.27
Package: PCRE related
Bug Type: Bug
Bug description:preg_split ignores limit flag when pattern with \K has 0-width fullstring match
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 bug report at https://bugs.php.net/bug.php?id=80865&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80865&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80865&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80865&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80865&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80865&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80865&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80865&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80865&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80865&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80865&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80865&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80865&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80865&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80865&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80865&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80865&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80865&r=mysqlcfg