Skip to content

Commit

Permalink
revert base64_encode change
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Mar 27, 2024
1 parent 9fae55f commit 6c5814d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 49 deletions.
2 changes: 1 addition & 1 deletion NEWS
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions UPGRADING
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion UPGRADING.INTERNALS
Expand Up @@ -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 '='.

========================
Expand Down
7 changes: 2 additions & 5 deletions ext/standard/base64.c
Expand Up @@ -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);
}
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/basic_functions.stub.php
Expand Up @@ -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
Expand Down
53 changes: 25 additions & 28 deletions ext/standard/basic_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions ext/standard/tests/url/base64_encode_basic_001.phpt
Expand Up @@ -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";
Expand Down Expand Up @@ -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

3 comments on commit 6c5814d

@Ayesh
Copy link
Contributor

@Ayesh Ayesh commented on 6c5814d Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, any reason why was this removed? Are we waiting for an RFC?

@TimWolla
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see the discussion starting here: #13698 (comment)

@Ayesh
Copy link
Contributor

@Ayesh Ayesh commented on 6c5814d Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thank you for pointing this out.

Please sign in to comment.