Bug #72694 [Ver->Csd]: mb_ereg_search_setpos does not accept a string's last position
| From: | cmb@php.net | Date: | Thu, 28 Jul 2016 13:58:55 +0000 |
| Subject: | Bug #72694 [Ver->Csd]: 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-202673@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: Verified
+Status: Closed
Type: Bug
Package: mbstring related
PHP Version: 5.6.24
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ee6900c3de68f1b94dfae8e230c7fa755c7fa595
Log: Fix #72694: mb_ereg_search_setpos does not accept a string's last position
Previous Comments:
------------------------------------------------------------------------
[2016-07-28 13:04:28] cmb@php.net
Confirmed: <https://3v4l.org/YqVeH>.
------------------------------------------------------------------------
[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