From d276e6a8386a68d57d5dd07c3d7e15de4b03c6b3 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 28 Jul 2016 13:07:05 +0200 Subject: [PATCH] Fix #72691: mb_ereg_search raises a warning if a match zero-width That warning doesn't make sense (PCRE doesn't throw such a warning either), so we remove it. --- NEWS | 5 ++++ ext/mbstring/php_mbregex.c | 3 -- ext/mbstring/tests/bug72691.phpt | 48 ++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 ext/mbstring/tests/bug72691.phpt diff --git a/NEWS b/NEWS index 3ab22a87aba..962be025812 100644 --- a/NEWS +++ b/NEWS @@ -40,6 +40,11 @@ PHP NEWS - Intl: . Partially fixed #72506 (idn_to_ascii for UTS #46 incorrect for long domain names). (cmb) + +- mbstring: + . Fixed bug #72691 (mb_ereg_search raises a warning if a match zero-width). + (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 67951a828e3..3509165ca9e 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1235,9 +1235,6 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) php_error_docref(NULL TSRMLS_CC, E_WARNING, "mbregex search failure in mbregex_search(): %s", err_str); RETVAL_FALSE; } else { - if (MBREX(search_regs)->beg[0] == MBREX(search_regs)->end[0]) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty regular expression"); - } switch (mode) { case 1: array_init(return_value); diff --git a/ext/mbstring/tests/bug72691.phpt b/ext/mbstring/tests/bug72691.phpt new file mode 100644 index 00000000000..d914a508e05 --- /dev/null +++ b/ext/mbstring/tests/bug72691.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #72691 (mb_ereg_search raises a warning if a match zero-width) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(1) +array(1) { + [0]=> + string(0) "" +} +int(2) +array(1) { + [0]=> + string(0) "" +} +int(3) +array(1) { + [0]=> + string(1) "o" +} +int(4) +array(1) { + [0]=> + string(0) "" +}