[php-src] master: revert base64_encode change
| From: | Remi Collet | Date: | Wed, 27 Mar 2024 07:08:57 +0000 |
| Subject: | [php-src] master: revert base64_encode change | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-127869@lists.php.net to get a copy of this message | ||
Author: Remi Collet (remicollet)
Date: 2024-03-27T08:08:43+01:00
Commit: https://github.com/php/php-src/commit/6c5814dade6ff5eff3f920246f7ea0c9e3321042
Raw diff: https://github.com/php/php-src/commit/6c5814dade6ff5eff3f920246f7ea0c9e3321042.diff
revert base64_encode change
Changed paths:
M NEWS
M UPGRADING
M UPGRADING.INTERNALS
M ext/standard/base64.c
M ext/standard/basic_functions.stub.php
M ext/standard/basic_functions_arginfo.h
M ext/standard/tests/url/base64_encode_basic_001.phpt
Diff:
diff --git a/NEWS b/NEWS
index 92385717b76c2..2d0ea8671a560 100644
--- a/NEWS
+++ b/NEWS
@@ -221,7 +221,7 @@ PHP NEWS
. Added the http_get_last_response_headers() and
http_clear_last_response_headers() that allows retrieving the same content
as the magic $http_response_header variable.
- . Add padding option to base64_encode. (Remi)
+ . Add php_base64_encode_ex() API. (Remi)
- XML:
. Added XML_OPTION_PARSE_HUGE parser option. (nielsdos)
diff --git a/UPGRADING b/UPGRADING
index e6aacce4bc646..ee8b6fcbea1b2 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -136,8 +136,6 @@ PHP 8.4 UPGRADE NOTES
PHP_ROUND_HALF_UP.
. strcspn() with empty $characters now returns the length of the string instead
of incorrectly stopping at the first NUL character. See GH-12592.
- . base64_encode now have a $padding option (true by default) to allow
- encoding without the padding character '='.
- XML:
. The xml_set_*_handler() functions now declare and check for an effective
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index 9abcbe57e83bb..6be15a7f9dcf0 100644
--- a/UPGRADING.INTERNALS
+++ b/UPGRADING.INTERNALS
@@ -213,7 +213,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
pcre2_set_compile_extra_options() with those options.
g. ext/standard
- - Added the base64_encode_ex() API with flag parameters, value can be
+ - Added the php_base64_encode_ex() API with flag parameters, value can be
PHP_BASE64_NO_PADDING to encode without the padding character '='.
========================
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index 9ea3e4717c5da..9c6a457b85832 100644
--- a/ext/standard/base64.c
+++ b/ext/standard/base64.c
@@ -1233,15 +1233,12 @@ PHP_FUNCTION(base64_encode)
char *str;
size_t str_len;
zend_string *result;
- bool padding = true;
- ZEND_PARSE_PARAMETERS_START(1, 2)
+ ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STRING(str, str_len)
- Z_PARAM_OPTIONAL
- Z_PARAM_BOOL(padding)
ZEND_PARSE_PARAMETERS_END();
- result = php_base64_encode_ex((unsigned char*)str, str_len, (padding ? 0 :
PHP_BASE64_NO_PADDING));
+ result = php_base64_encode((unsigned char*)str, str_len);
RETURN_STR(result);
}
/* }}} */
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php
index 21a829267c726..c3adaceff4390 100644
--- a/ext/standard/basic_functions.stub.php
+++ b/ext/standard/basic_functions.stub.php
@@ -1930,7 +1930,7 @@ function array_is_list(array $array): bool {}
* @compile-time-eval
* @refcount 1
*/
-function base64_encode(string $string, bool $padding = true): string {}
+function base64_encode(string $string): string {}
/**
* @compile-time-eval
diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h
index c316cda685ee8..c420e5c29e0f7 100644
--- a/ext/standard/basic_functions_arginfo.h
+++ b/ext/standard/basic_functions_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 8ae13d072715cee48915fdfd1c47fc3a9027d21a */
+ * Stub hash: 954bf48ac1f24a14fd7508c8bf4b781883398499 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
@@ -366,7 +366,6 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_base64_encode, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, padding, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_base64_decode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
@@ -799,9 +798,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_assert_options, 0, 1, IS_MIXED,
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bin2hex, 0, 1, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
-ZEND_END_ARG_INFO()
+#define arginfo_bin2hex arginfo_base64_encode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hex2bin, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
@@ -863,13 +860,13 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtok, 0, 1,
MAY_BE_STRING|MAY_
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, token, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
-#define arginfo_strtoupper arginfo_bin2hex
+#define arginfo_strtoupper arginfo_base64_encode
-#define arginfo_strtolower arginfo_bin2hex
+#define arginfo_strtolower arginfo_base64_encode
-#define arginfo_str_increment arginfo_bin2hex
+#define arginfo_str_increment arginfo_base64_encode
-#define arginfo_str_decrement arginfo_bin2hex
+#define arginfo_str_decrement arginfo_base64_encode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_basename, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0)
@@ -938,7 +935,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_substr_replace, 0, 3, MAY_BE_STR
ZEND_ARG_TYPE_MASK(0, length, MAY_BE_ARRAY|MAY_BE_LONG|MAY_BE_NULL, "null")
ZEND_END_ARG_INFO()
-#define arginfo_quotemeta arginfo_bin2hex
+#define arginfo_quotemeta arginfo_base64_encode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ord, 0, 1, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, character, IS_STRING, 0)
@@ -948,9 +945,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_chr, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, codepoint, IS_LONG, 0)
ZEND_END_ARG_INFO()
-#define arginfo_ucfirst arginfo_bin2hex
+#define arginfo_ucfirst arginfo_base64_encode
-#define arginfo_lcfirst arginfo_bin2hex
+#define arginfo_lcfirst arginfo_base64_encode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ucwords, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
@@ -963,7 +960,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strtr, 0, 2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, to, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
-#define arginfo_strrev arginfo_bin2hex
+#define arginfo_strrev arginfo_base64_encode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_similar_text, 0, 2, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, string1, IS_STRING, 0)
@@ -976,11 +973,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_addcslashes, 0, 2, IS_STRING,
0)
ZEND_ARG_TYPE_INFO(0, characters, IS_STRING, 0)
ZEND_END_ARG_INFO()
-#define arginfo_addslashes arginfo_bin2hex
+#define arginfo_addslashes arginfo_base64_encode
-#define arginfo_stripcslashes arginfo_bin2hex
+#define arginfo_stripcslashes arginfo_base64_encode
-#define arginfo_stripslashes arginfo_bin2hex
+#define arginfo_stripslashes arginfo_base64_encode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_str_replace, 0, 3, MAY_BE_STRING|MAY_BE_ARRAY)
ZEND_ARG_TYPE_MASK(0, search, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
@@ -1060,9 +1057,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_sscanf, 0, 2,
MAY_BE_ARRAY|MAY_B
ZEND_ARG_VARIADIC_TYPE_INFO(1, vars, IS_MIXED, 0)
ZEND_END_ARG_INFO()
-#define arginfo_str_rot13 arginfo_bin2hex
+#define arginfo_str_rot13 arginfo_base64_encode
-#define arginfo_str_shuffle arginfo_bin2hex
+#define arginfo_str_shuffle arginfo_base64_encode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_str_word_count, 0, 1, MAY_BE_ARRAY|MAY_BE_LONG)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
@@ -1088,9 +1085,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_substr_compare, 0, 3, IS_LONG,
0
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, case_insensitive, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
-#define arginfo_utf8_encode arginfo_bin2hex
+#define arginfo_utf8_encode arginfo_base64_encode
-#define arginfo_utf8_decode arginfo_bin2hex
+#define arginfo_utf8_decode arginfo_base64_encode
ZEND_BEGIN_ARG_INFO_EX(arginfo_opendir, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, directory, IS_STRING, 0)
@@ -1814,11 +1811,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_proc_get_status, 0, 1,
IS_ARRAY,
ZEND_END_ARG_INFO()
#endif
-#define arginfo_quoted_printable_decode arginfo_bin2hex
+#define arginfo_quoted_printable_decode arginfo_base64_encode
-#define arginfo_quoted_printable_encode arginfo_bin2hex
+#define arginfo_quoted_printable_encode arginfo_base64_encode
-#define arginfo_soundex arginfo_bin2hex
+#define arginfo_soundex arginfo_base64_encode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_stream_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(1, read, IS_ARRAY, 1)
@@ -2093,13 +2090,13 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_parse_url, 0, 1,
MAY_BE_LONG|MAY
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, component, IS_LONG, 0, "-1")
ZEND_END_ARG_INFO()
-#define arginfo_urlencode arginfo_bin2hex
+#define arginfo_urlencode arginfo_base64_encode
-#define arginfo_urldecode arginfo_bin2hex
+#define arginfo_urldecode arginfo_base64_encode
-#define arginfo_rawurlencode arginfo_bin2hex
+#define arginfo_rawurlencode arginfo_base64_encode
-#define arginfo_rawurldecode arginfo_bin2hex
+#define arginfo_rawurldecode arginfo_base64_encode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_get_headers, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, url, IS_STRING, 0)
@@ -2130,7 +2127,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_stream_filter_register, 0, 2,
_I
ZEND_ARG_TYPE_INFO(0, class, IS_STRING, 0)
ZEND_END_ARG_INFO()
-#define arginfo_convert_uuencode arginfo_bin2hex
+#define arginfo_convert_uuencode arginfo_base64_encode
#define arginfo_convert_uudecode arginfo_hex2bin
diff --git a/ext/standard/tests/url/base64_encode_basic_001.phpt
b/ext/standard/tests/url/base64_encode_basic_001.phpt
index cb555c2ebcd5a..7d74696eb80da 100644
--- a/ext/standard/tests/url/base64_encode_basic_001.phpt
+++ b/ext/standard/tests/url/base64_encode_basic_001.phpt
@@ -29,8 +29,6 @@ $values = array(
foreach($values as $str) {
$enc = base64_encode($str);
printf("%s\n", $enc);
- $enc = base64_encode($str, padding: false);
- printf("%s\n", $enc);
}
echo "Done\n";
@@ -294,21 +292,12 @@ echo "Done\n";
0xFE: /g==
0xFF: /w==
SGVsbG8gV29ybGQ=
-SGVsbG8gV29ybGQ
QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY3ODkwISVeJiooKXt9W10=
-QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY3ODkwISVeJiooKXt9W10
-CgkgTGluZSB3aXRoIGNvbnRyb2wgY2hhcmFjdGVycw0K
CgkgTGluZSB3aXRoIGNvbnRyb2wgY2hhcmFjdGVycw0K
wcLDxMXG
-wcLDxMXG
PT4/BzgHOVw4MA==
-PT4/BzgHOVw4MA
QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIQ==
-QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIQ
QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIT0+Pwc4BzlcODA=
-QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIT0+Pwc4BzlcODA
QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5JSE=
-QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5JSE
-QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5JSE9Pj8HOAc5XDgw
QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5JSE9Pj8HOAc5XDgw
Done