Skip to content

Commit 0fbebfd

Browse files
committed
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.
1 parent 84be22f commit 0fbebfd

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

ext/standard/basic_functions.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,9 @@ function headers_list(): array {}
519519

520520
function htmlspecialchars(string $string, int $quote_style = ENT_COMPAT, ?string $encoding = null, bool $double_encode = true): string {}
521521

522-
function htmlspecialchars_decode(string $string, int $quote_style = ENT_COMPAT): string|false {}
522+
function htmlspecialchars_decode(string $string, int $quote_style = ENT_COMPAT): string {}
523523

524-
function html_entity_decode(string $string, int $quote_style = ENT_COMPAT, ?string $encoding = null): string|false {}
524+
function html_entity_decode(string $string, int $quote_style = ENT_COMPAT, ?string $encoding = null): string {}
525525

526526
function htmlentities(string $string, int $quote_style = ENT_COMPAT, ?string $encoding = null, bool $double_encode = true): string {}
527527

ext/standard/basic_functions_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 5d9126adf07f6f480b5879f551de466140b98462 */
2+
* Stub hash: 02f033de2ff8c06e24b22b150baa1a503ce6b95e */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
55
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
770770
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, double_encode, _IS_BOOL, 0, "true")
771771
ZEND_END_ARG_INFO()
772772

773-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_htmlspecialchars_decode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
773+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_htmlspecialchars_decode, 0, 1, IS_STRING, 0)
774774
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
775775
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, quote_style, IS_LONG, 0, "ENT_COMPAT")
776776
ZEND_END_ARG_INFO()
777777

778-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_html_entity_decode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
778+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_html_entity_decode, 0, 1, IS_STRING, 0)
779779
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
780780
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, quote_style, IS_LONG, 0, "ENT_COMPAT")
781781
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")

ext/standard/html.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,10 +1377,7 @@ PHP_FUNCTION(htmlspecialchars_decode)
13771377
ZEND_PARSE_PARAMETERS_END();
13781378

13791379
replaced = php_unescape_html_entities(str, 0 /*!all*/, (int)quote_style, NULL);
1380-
if (replaced) {
1381-
RETURN_STR(replaced);
1382-
}
1383-
RETURN_FALSE;
1380+
RETURN_STR(replaced);
13841381
}
13851382
/* }}} */
13861383

@@ -1400,11 +1397,7 @@ PHP_FUNCTION(html_entity_decode)
14001397

14011398
replaced = php_unescape_html_entities(
14021399
str, 1 /*all*/, (int)quote_style, hint_charset ? ZSTR_VAL(hint_charset) : NULL);
1403-
1404-
if (replaced) {
1405-
RETURN_STR(replaced);
1406-
}
1407-
RETURN_FALSE;
1400+
RETURN_STR(replaced);
14081401
}
14091402
/* }}} */
14101403

0 commit comments

Comments
 (0)