Bug #72694 [NEW]: mb_ereg_search_setpos does not accept a string's last position

From: Date: Thu, 28 Jul 2016 06:01:33 +0000
Subject: Bug #72694 [NEW]: mb_ereg_search_setpos does not accept a string's last position
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202655@lists.php.net to get a copy of this message
From: ju1ius at laposte dot net Operating system: PHP version: 5.6.24 Package: mbstring related Bug Type: Bug Bug description:mb_ereg_search_setpos does not accept a string's last position Description: ------------ When calling mb_ereg_search_setpos with the end position of a string as argument, it raises a warning and returns false and resets the search position to zero. This prevents mb_ereg_search to match at the end of the string (for example zero-width assertions like '\Z', '$' or lookbehinds). The correct behavior should be to not throw a warning, and set the position accordingly. What's more, once you call mb_ereg_search_setpos(strlen($str)), the mb_ereg_search behavior seems to be erratic, see the test script, where the '\Z' assertion matches and sets position to 3 eventhough mb_ereg_search_getpos just returned 0 ! Test script: --------------- mb_ereg_search_init('foo'); var_dump(mb_ereg_search_setpos(3)); var_dump(mb_ereg_search_getpos()); var_dump(mb_ereg_search('\Z')); var_dump(mb_ereg_search_getpos()); Expected result: ---------------- bool(true) int(3) bool(true) int(3) Actual result: -------------- Warning: mb_ereg_search_setpos(): Position is out of range in ... bool(false) int(0) Warning: mb_ereg_search(): Empty regular expression in ... bool(true) int(3) -- Edit bug report at https://bugs.php.net/bug.php?id=72694&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72694&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72694&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72694&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72694&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72694&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72694&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72694&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72694&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72694&r=support Expected behavior: https://bugs.php.net/fix.php?id=72694&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72694&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72694&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72694&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72694&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72694&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72694&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72694&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72694&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72694&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72694&r=mysqlcfg

« previous php.bugs (#202655) next »