diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-09-22 11:23:01 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-09-22 11:23:01 +0200 |
commit | 0fbebfd1ae3dfc8d9e088abbb6b062f5c86f2587 (patch) | |
tree | 3e98ba32069f8d09a42ec3d4e5ce23ba36b6d273 | |
parent | 84be22f1f5db499001379f762869d00fc3bc6f55 (diff) | |
download | php-git-0fbebfd1ae3dfc8d9e088abbb6b062f5c86f2587.tar.gz |
html_entity_decode() cannot fail
php_unescape_html_entities() never returns null, so this function
can never return false.
php_unescape_html_entities() probably should be failing with OOM
for the "overflow" case, but even if it did, it would not be
signalled through a false return value.
-rwxr-xr-x | ext/standard/basic_functions.stub.php | 4 | ||||
-rw-r--r-- | ext/standard/basic_functions_arginfo.h | 6 | ||||
-rw-r--r-- | ext/standard/html.c | 11 |
3 files changed, 7 insertions, 14 deletions
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 74a049831c..0f59a2bdcd 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -519,9 +519,9 @@ function headers_list(): array {} function htmlspecialchars(string $string, int $quote_style = ENT_COMPAT, ?string $encoding = null, bool $double_encode = true): string {} -function htmlspecialchars_decode(string $string, int $quote_style = ENT_COMPAT): string|false {} +function htmlspecialchars_decode(string $string, int $quote_style = ENT_COMPAT): string {} -function html_entity_decode(string $string, int $quote_style = ENT_COMPAT, ?string $encoding = null): string|false {} +function html_entity_decode(string $string, int $quote_style = ENT_COMPAT, ?string $encoding = null): string {} function htmlentities(string $string, int $quote_style = ENT_COMPAT, ?string $encoding = null, bool $double_encode = true): string {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 5c63fb509a..6ca9dfc34c 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: 5d9126adf07f6f480b5879f551de466140b98462 */ + * Stub hash: 02f033de2ff8c06e24b22b150baa1a503ce6b95e */ 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) @@ -770,12 +770,12 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_htmlspecialchars, 0, 1, IS_STRIN ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, double_encode, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_htmlspecialchars_decode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_htmlspecialchars_decode, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, quote_style, IS_LONG, 0, "ENT_COMPAT") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_html_entity_decode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_html_entity_decode, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, quote_style, IS_LONG, 0, "ENT_COMPAT") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") diff --git a/ext/standard/html.c b/ext/standard/html.c index 463e55c255..c949e058c1 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1377,10 +1377,7 @@ PHP_FUNCTION(htmlspecialchars_decode) ZEND_PARSE_PARAMETERS_END(); replaced = php_unescape_html_entities(str, 0 /*!all*/, (int)quote_style, NULL); - if (replaced) { - RETURN_STR(replaced); - } - RETURN_FALSE; + RETURN_STR(replaced); } /* }}} */ @@ -1400,11 +1397,7 @@ PHP_FUNCTION(html_entity_decode) replaced = php_unescape_html_entities( str, 1 /*all*/, (int)quote_style, hint_charset ? ZSTR_VAL(hint_charset) : NULL); - - if (replaced) { - RETURN_STR(replaced); - } - RETURN_FALSE; + RETURN_STR(replaced); } /* }}} */ |