com php-src: Fix #72694: mb_ereg_search_setpos does n ot accept a string's last position: NEWS ext/ mbstring/php_mbregex.c ext/mbstring/tests/bug7269
4.phpt

From: Date: Thu, 28 Jul 2016 13:21:48 +0000
Subject: com php-src: Fix #72694: mb_ereg_search_setpos does n ot accept a string's last position: NEWS ext/ mbstring/php_mbregex.c ext/mbstring/tests/bug7269
4.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-93453@lists.php.net to get a copy of this message
Commit: ee6900c3de68f1b94dfae8e230c7fa755c7fa595 Author: Christoph M. Becker <cmb@php.net> Thu, 28 Jul 2016 15:21:48 +0200 Parents: 56cdaecb284b2b292ce1ecb076c1f8b041e47a02 Branches: PHP-5.6 PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ee6900c3de68f1b94dfae8e230c7fa755c7fa595 Log: Fix #72694: mb_ereg_search_setpos does not accept a string's last position Setting the search position immediately behind the last character should be allowed, so we fix this off-by-one error. Bugs: https://bugs.php.net/72694 Changed paths: M NEWS M ext/mbstring/php_mbregex.c A ext/mbstring/tests/bug72694.phpt Diff: diff --git a/NEWS b/NEWS index 7a0e890..44cd6e1 100644 --- a/NEWS +++ b/NEWS @@ -44,8 +44,10 @@ 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 + . Fixed bug #72693 (mb_ereg_search increments search position when a match zero-width). (cmb) + . Fixed bug #72694 (mb_ereg_search_setpos does not accept a string's last + position). (cmb) - PCRE: . Fixed bug #72688 (preg_match missing group names in matches). (cmb) diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index a295f54..9873a85 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1400,7 +1400,7 @@ PHP_FUNCTION(mb_ereg_search_setpos) return; } - if (position < 0 || (MBREX(search_str) != NULL && Z_TYPE_P(MBREX(search_str)) == IS_STRING && position >= Z_STRLEN_P(MBREX(search_str)))) { + if (position < 0 || (MBREX(search_str) != NULL && Z_TYPE_P(MBREX(search_str)) == IS_STRING && position > Z_STRLEN_P(MBREX(search_str)))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Position is out of range"); MBREX(search_pos) = 0; RETURN_FALSE; diff --git a/ext/mbstring/tests/bug72694.phpt b/ext/mbstring/tests/bug72694.phpt new file mode 100644 index 0000000..90f56a3 --- /dev/null +++ b/ext/mbstring/tests/bug72694.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #72694 (mb_ereg_search_setpos does not accept a string's last position) +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip ext/mbstring required'); +?> +--FILE-- +<?php +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()); +?> +--EXPECT-- +bool(true) +int(3) +bool(true) +int(3)

« previous php.cvs (#93453) next »