Req #44585 [Opn->Sus]: htmlentities returns empty string when operation on a null value

From: Date: Sun, 05 Jan 2020 11:14:07 +0000
Subject: Req #44585 [Opn->Sus]: htmlentities returns empty string when operation on a null value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224707@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=44585&edit=1 ID: 44585 Updated by: cmb@php.net Reported by: eran at octabox dot com Summary: htmlentities returns empty string when operation on a null value -Status: Open +Status: Suspended Type: Feature/Change Request Package: Strings related Operating System: Windows XP Professional SP2 PHP Version: 5.2.5 Block user comment: N Private report: N New Comment: htmlentities() expects a string as first argument, and due to PHP's type juggling a NULL is converted to an empty string. If you want to have that changed, please pursue the RFC process[1]. [1] <https://wiki.php.net/rfc/howto> Previous Comments: ------------------------------------------------------------------------ [2008-04-01 03:14:43] eran at octabox dot com Description: ------------ The htmlentities function returns an empty string when used on a null value. This might seem irrelevant, however the htmlentities is used regularly to escape data before using it in a database query. A null value might be needed in such queries, and it would be preferred if it does not need to be considered a special case if a part of an data escaping routine. For example, the Zend_Filter_Input component of the Zend_Framework uses htmlentities as the default escape filter. Passing null values in an escape routing would result in null values erroneously being converted to empty strings. Reproduce code: --------------- var_dump(htmlentities(null)); Expected result: ---------------- NULL Actual result: -------------- string(0) "" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=44585&edit=1

« previous php.bugs (#224707) next »