From: Nikita Popov Date: Tue, 22 Sep 2020 10:39:39 +0000 (+0200) Subject: Support uuencoding empty string X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fdd9018bdfa6a4b99279a982e7c9d490849c8ae4;p=php Support uuencoding empty string Cross checking implementations from other languages, empty strings are always allowed. PHP's output is peculiar due to it's insistence to encode a trailing \0, but otherwise sensible and does round-trip as expected. --- diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 0ae34307e5..e3a2588028 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -213,7 +213,7 @@ static const func_info_t func_infos[] = { F1("base64_encode", MAY_BE_STRING), F1("password_hash", MAY_BE_STRING), F1("password_get_info", MAY_BE_NULL | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY), - F1("convert_uuencode", MAY_BE_FALSE | MAY_BE_STRING), + F1("convert_uuencode", MAY_BE_STRING), F1("convert_uudecode", MAY_BE_FALSE | MAY_BE_STRING), F1("pow", MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_OBJECT), F1("decbin", MAY_BE_STRING), diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 03615f3bdb..0bc7bd8aef 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1465,7 +1465,7 @@ function stream_filter_register(string $filtername, string $classname): bool {} /* uuencode.c */ -function convert_uuencode(string $data): string|false {} +function convert_uuencode(string $data): string {} function convert_uudecode(string $data): string|false {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 01292812d2..6aff74adcf 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: 621176b0f79f4fcb833c6be568adb2070239cce1 */ + * Stub hash: 3c02183529eed2eb21d801ed2ba615deaf749b1d */ 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) @@ -2158,7 +2158,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_stream_filter_register, 0, 2, _I ZEND_ARG_TYPE_INFO(0, classname, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_convert_uuencode arginfo_hex2bin +#define arginfo_convert_uuencode arginfo_bin2hex #define arginfo_convert_uudecode arginfo_hex2bin diff --git a/ext/standard/tests/strings/uuencode.phpt b/ext/standard/tests/strings/uuencode.phpt index b0a2a2321d..d03c2b1bf0 100644 --- a/ext/standard/tests/strings/uuencode.phpt +++ b/ext/standard/tests/strings/uuencode.phpt @@ -3,20 +3,22 @@ uuencode family tests --FILE-- --EXPECTF-- -bool(false) -bool(false) +string(2) "` +" +string(0) "" string(60) "J?B%`(R0E7B8J*"E??7M03TE5651215=145-$1D=(2DM,.CQ-3D)60UA: ` " @@ -27,6 +29,9 @@ string(36) "6;F]T('9E