Bug #72694 [Opn->Ver]: mb_ereg_search_setpos does not accept a string's last position

From: Date: Thu, 28 Jul 2016 13:04:29 +0000
Subject: Bug #72694 [Opn->Ver]: mb_ereg_search_setpos does not accept a string's last position
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202672@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72694&edit=1 ID: 72694 Updated by: cmb@php.net Reported by: ju1ius at laposte dot net Summary: mb_ereg_search_setpos does not accept a string's last position -Status: Open +Status: Verified Type: Bug Package: mbstring related PHP Version: 5.6.24 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Confirmed: <https://3v4l.org/YqVeH>. Previous Comments: ------------------------------------------------------------------------ [2016-07-28 06:01:28] ju1ius at laposte dot net 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 this bug report at https://bugs.php.net/bug.php?id=72694&edit=1

« previous php.bugs (#202672) next »