Bug #80977 [NEW]: mb_ereg_search_pos is not multibyte-safe
| From: | v dot picture at free dot fr | Date: | Thu, 22 Apr 2021 15:08:36 +0000 |
| Subject: | Bug #80977 [NEW]: mb_ereg_search_pos is not multibyte-safe | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-233556@lists.php.net to get a copy of this message | ||
From: v dot picture at free dot fr
Operating system: Linux
PHP version: 8.0.3
Package: Regexps related
Bug Type: Bug
Bug description:mb_ereg_search_pos is not multibyte-safe
Description:
------------
Hello,
The mb_ereg_search_pos function is absolutely not multibyte-safe, it
actually returns the position of the match as if the string was not
multibyte.
The results of this function are exactly the same as if you were using
preg_match_all with PREG_OFFSET_CAPTURE, even with the "unicode" flag
it's simply NOT working.
Test script:
---------------
$string = 'jème lé ponés';
mb_ereg_search_init($string, '(?<=[ ^])\w+'); // Detect words
while ($pos = mb_ereg_search_pos()) {
$match = mb_ereg_search_getregs()[0];
$matchBasedOnPos = mb_substr($string, $pos[0], $pos[1]);
if ($matchBasedOnPos !== $match) {
throw new \LogicException("Match based on position
'{$matchBasedOnPos}' does not correspond to actual match '{$match}'");
}
}
Expected result:
----------------
No exception thrown
Actual result:
--------------
LogicException: Match based on position 'é p' does not correspond to
actual match 'lé'
--
Edit bug report at https://bugs.php.net/bug.php?id=80977&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80977&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80977&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80977&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80977&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80977&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80977&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80977&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80977&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80977&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80977&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80977&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80977&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80977&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80977&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80977&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80977&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80977&r=mysqlcfg