php-src/ext/mbstring
Nikita Popov 5582490bf2 Normalize mb_ereg() return value
mb_ereg()/mb_eregi() currently have an inconsistent return value
based on whether the $matches parameter is passed or not:

> Returns the byte length of the matched string if a match for
> pattern was found in string, or FALSE if no matches were found
> or an error occurred.
>
> If the optional parameter regs was not passed or the length of
> the matched string is 0, this function returns 1.

Coupling this behavior to the $matches parameter doesn't make sense
-- we know the match length either way, there is no technical
reason to distinguish them. However, returning the match length
is not particularly useful either, especially due to the need to
convert 0-length into 1-length to satisfy "truthy" checks. We
could always return 1, which would kind of match the behavior of
preg_match() -- however, preg_match() actually returns the number
of matches, which is 0 or 1 for preg_match(), while false signals
an error. However, mb_ereg() returns false both for no match and
for an error. This would result in an odd 1|false return value.

The patch canonicalizes mb_ereg() to always return a boolean,
where true indicates a match and false indicates no match or error.
This also matches the behavior of the mb_ereg_match() and
mb_ereg_search() functions.

This fixes the default value integrity violation in PHP 8.

Closes GH-6331.
2020-10-13 20:40:55 +02:00
..
libmbfl fix mbfl function prototypes 2020-09-15 15:15:06 +02:00
tests Normalize mb_ereg() return value 2020-10-13 20:40:55 +02:00
ucgendat [ci skip] Move OpenLDAP license to redistributable info file 2019-05-06 23:02:46 +02:00
config.m4 Remove redundant includes from mbstring (and make sure correct config.h is used) 2020-08-31 23:17:58 +02:00
config.w32 Remove redundant includes from mbstring (and make sure correct config.h is used) 2020-08-31 23:17:58 +02:00
CREDITS
mb_gpc.c Don't guard mbstring code with #ifdef HAVE_MBSTRING 2020-08-31 23:18:13 +02:00
mb_gpc.h Don't guard mbstring code with #ifdef HAVE_MBSTRING 2020-08-31 23:18:13 +02:00
mbstring_arginfo.h Normalize mb_ereg() return value 2020-10-13 20:40:55 +02:00
mbstring.c Fix incorrect zpp parameter count in mb_substr() / mb_strcut() 2020-10-13 17:46:56 +02:00
mbstring.h Don't guard mbstring code with #ifdef HAVE_MBSTRING 2020-08-31 23:18:13 +02:00
mbstring.stub.php Normalize mb_ereg() return value 2020-10-13 20:40:55 +02:00
php_mbregex.c Normalize mb_ereg() return value 2020-10-13 20:40:55 +02:00
php_mbregex.h Fix [-Wundef] warning in MBString extension 2020-05-16 15:31:20 +02:00
php_onig_compat.h
php_unicode.c Don't guard mbstring code with #ifdef HAVE_MBSTRING 2020-08-31 23:18:13 +02:00
php_unicode.h Don't guard mbstring code with #ifdef HAVE_MBSTRING 2020-08-31 23:18:13 +02:00
unicode_data.h Update Unicode tables to 13.0.0 2020-03-12 11:29:51 +01:00