mirror of
https://github.com/php/php-src.git
synced 2024-11-27 20:03:40 +08:00
Fix #72693: mb_ereg_search increments search position when a match zero-width
That's caused by an off-by-one error, which we fix.
This commit is contained in:
parent
d276e6a838
commit
56cdaecb28
2
NEWS
2
NEWS
@ -44,6 +44,8 @@ PHP NEWS
|
||||
- mbstring:
|
||||
. Fixed bug #72691 (mb_ereg_search raises a warning if a match zero-width).
|
||||
(cmb)
|
||||
. Fixed Bug #72693 (mb_ereg_search increments search position when a match
|
||||
zero-width). (cmb)
|
||||
|
||||
- PCRE:
|
||||
. Fixed bug #72688 (preg_match missing group names in matches). (cmb)
|
||||
|
@ -1261,7 +1261,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
|
||||
break;
|
||||
}
|
||||
end = MBREX(search_regs)->end[0];
|
||||
if (pos < end) {
|
||||
if (pos <= end) {
|
||||
MBREX(search_pos) = end;
|
||||
} else {
|
||||
MBREX(search_pos) = pos + 1;
|
||||
|
@ -26,12 +26,12 @@ var_dump(mb_ereg_search_getpos());
|
||||
var_dump(mb_ereg_search_getregs());
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
||||
int(0)
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(0) ""
|
||||
}
|
||||
int(2)
|
||||
int(0)
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(0) ""
|
||||
@ -39,9 +39,9 @@ array(1) {
|
||||
int(3)
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "o"
|
||||
string(3) "foo"
|
||||
}
|
||||
int(4)
|
||||
int(3)
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(0) ""
|
||||
|
41
ext/mbstring/tests/bug72693.phpt
Normal file
41
ext/mbstring/tests/bug72693.phpt
Normal file
@ -0,0 +1,41 @@
|
||||
--TEST--
|
||||
Bug #72693 (mb_ereg_search increments search position when a match zero-width)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('mbstring')) die('skip ext/mbstring required');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
mb_ereg_search_init('foo');
|
||||
|
||||
var_dump(mb_ereg_search('\A'));
|
||||
var_dump(mb_ereg_search_getpos());
|
||||
|
||||
var_dump(mb_ereg_search('\s*'));
|
||||
var_dump(mb_ereg_search_getpos());
|
||||
|
||||
var_dump(mb_ereg_search('\w+'));
|
||||
var_dump(mb_ereg_search_getpos());
|
||||
var_dump(mb_ereg_search_getregs());
|
||||
|
||||
var_dump(mb_ereg_search('\s*'));
|
||||
var_dump(mb_ereg_search_getpos());
|
||||
|
||||
var_dump(mb_ereg_search('\Z'));
|
||||
var_dump(mb_ereg_search_getpos());
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
int(0)
|
||||
bool(true)
|
||||
int(0)
|
||||
bool(true)
|
||||
int(3)
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "foo"
|
||||
}
|
||||
bool(true)
|
||||
int(3)
|
||||
bool(true)
|
||||
int(3)
|
Loading…
Reference in New Issue
Block a user