com php-src: Return empty str from quotemeta() on empty str: UPGRADING ext/opcache/Optimizer/zend_func_info.c ext/standard/str ing.c
ext/standard/tests/strings/quotemeta_basic_1. phpt
| From: | Nikita Popov | Date: | Mon, 11 Feb 2019 08:58:10 +0000 |
| Subject: | com php-src: Return empty str from quotemeta() on empty str: UPGRADING ext/opcache/Optimizer/zend_func_info.c ext/standard/str ing.c ext/standard/tests/strings/quotemeta_basic_1. phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104534@lists.php.net to get a copy of this message | ||
Commit: fdb85a828a4b0322db55e2e9034a8c66a423a959
Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 11 Feb 2019 09:58:10 +0100
Parents: ab48b45f6c91e1a1bddf2c775a669ef1a294faf1
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fdb85a828a4b0322db55e2e9034a8c66a423a959
Log:
Return empty str from quotemeta() on empty str
Changed paths:
M UPGRADING
M ext/opcache/Optimizer/zend_func_info.c
M ext/standard/string.c
M ext/standard/tests/strings/quotemeta_basic_1.phpt
Diff:
diff --git a/UPGRADING b/UPGRADING
index 850f3fc..1ca0d2a 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -148,6 +148,8 @@ PHP 8.0 UPGRADE NOTES
. 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
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:
. gzgetss() has been removed.
diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c
index 7298059..7064093 100644
--- a/ext/opcache/Optimizer/zend_func_info.c
+++ b/ext/opcache/Optimizer/zend_func_info.c
@@ -340,7 +340,7 @@ static const func_info_t func_infos[] = {
#endif
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),
- 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("lcfirst", MAY_BE_NULL | MAY_BE_STRING),
F1("ucwords", MAY_BE_NULL | MAY_BE_STRING),
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 8009889..7f12cfa 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2592,8 +2592,8 @@ PHP_FUNCTION(quotemeta)
old_end = ZSTR_VAL(old) + ZSTR_LEN(old);
- if (ZSTR_VAL(old) == old_end) {
- RETURN_FALSE;
+ if (ZSTR_LEN(old) == 0) {
+ RETURN_EMPTY_STRING();
}
str = zend_string_safe_alloc(2, ZSTR_LEN(old), 0, 0);
diff --git a/ext/standard/tests/strings/quotemeta_basic_1.phpt
b/ext/standard/tests/strings/quotemeta_basic_1.phpt
index 4b479a9..4d1feb5 100644
--- a/ext/standard/tests/strings/quotemeta_basic_1.phpt
+++ b/ext/standard/tests/strings/quotemeta_basic_1.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test function quotemeta() - using an empty string is given as str.
+Test function quotemeta() - using an empty string is given as str
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
User Group: PHPSP #PHPTestFestBrasil
@@ -9,4 +9,4 @@ $str = "";
var_dump(quotemeta($str));
?>
--EXPECT--
-bool(false)
+string(0) ""