mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Return empty str from quotemeta() on empty str
This commit is contained in:
parent
ab48b45f6c
commit
fdb85a828a
4 changed files with 7 additions and 5 deletions
|
@ -148,6 +148,8 @@ PHP 8.0 UPGRADE NOTES
|
||||||
. The 'salt' option of password_hash() is no longer supported. If the 'salt'
|
. The 'salt' option of password_hash() is no longer supported. If the 'salt'
|
||||||
option is used a warning is generated, the provided salt is ignored, and a
|
option is used a warning is generated, the provided salt is ignored, and a
|
||||||
generated salt is used instead.
|
generated salt is used instead.
|
||||||
|
. The quotemeta() function will now return an empty string if an empty string
|
||||||
|
was passed. Previously false was returned.
|
||||||
|
|
||||||
- Zlib:
|
- Zlib:
|
||||||
. gzgetss() has been removed.
|
. gzgetss() has been removed.
|
||||||
|
|
|
@ -340,7 +340,7 @@ static const func_info_t func_infos[] = {
|
||||||
#endif
|
#endif
|
||||||
FN("substr", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
|
FN("substr", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
|
||||||
FN("substr_replace", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING),
|
FN("substr_replace", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING),
|
||||||
F1("quotemeta", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
|
F1("quotemeta", MAY_BE_NULL | MAY_BE_STRING),
|
||||||
FN("ucfirst", MAY_BE_NULL | MAY_BE_STRING),
|
FN("ucfirst", MAY_BE_NULL | MAY_BE_STRING),
|
||||||
FN("lcfirst", MAY_BE_NULL | MAY_BE_STRING),
|
FN("lcfirst", MAY_BE_NULL | MAY_BE_STRING),
|
||||||
F1("ucwords", MAY_BE_NULL | MAY_BE_STRING),
|
F1("ucwords", MAY_BE_NULL | MAY_BE_STRING),
|
||||||
|
|
|
@ -2592,8 +2592,8 @@ PHP_FUNCTION(quotemeta)
|
||||||
|
|
||||||
old_end = ZSTR_VAL(old) + ZSTR_LEN(old);
|
old_end = ZSTR_VAL(old) + ZSTR_LEN(old);
|
||||||
|
|
||||||
if (ZSTR_VAL(old) == old_end) {
|
if (ZSTR_LEN(old) == 0) {
|
||||||
RETURN_FALSE;
|
RETURN_EMPTY_STRING();
|
||||||
}
|
}
|
||||||
|
|
||||||
str = zend_string_safe_alloc(2, ZSTR_LEN(old), 0, 0);
|
str = zend_string_safe_alloc(2, ZSTR_LEN(old), 0, 0);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test function quotemeta() - using an empty string is given as str.
|
Test function quotemeta() - using an empty string is given as str
|
||||||
--CREDITS--
|
--CREDITS--
|
||||||
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
|
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
|
||||||
User Group: PHPSP #PHPTestFestBrasil
|
User Group: PHPSP #PHPTestFestBrasil
|
||||||
|
@ -9,4 +9,4 @@ $str = "";
|
||||||
var_dump(quotemeta($str));
|
var_dump(quotemeta($str));
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
bool(false)
|
string(0) ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue