Bug #53109 [Opn->Fbk]: htmlentities and htmlspecialchars problems with __toString
Edit report at http://bugs.php.net/bug.php?id=53109&edit=1
ID: 53109
Updated by: cataphract@php.net
Reported by: ibber_of_crew42 at hotmail dot com
Summary: htmlentities and htmlspecialchars problems with
__toString
-Status: Open
+Status: Feedback
Type: Bug
Package: Strings related
Operating System: Irrelevant
PHP Version: 5.2.14
Block user comment: N
New Comment:
Thanks for your report.
However, I can't reproduce this with:
<?php
class A {
function __tostring() { return "aaa"; }
}
echo htmlspecialchars(new A());
Passing it to parameter 2, gives a message telling parameter 2 should be
long, object given.
There's nothing out of the ordinary with the implementation of
htmlentities/htmlspecialchars, so unless you have a way to reproduce
this, I'll close it as bogus in the next few days.
Previous Comments:
------------------------------------------------------------------------
[2010-10-20 08:36:38] ibber_of_crew42 at hotmail dot com
Description:
------------
When passing an instance of a class implementing __toString, as the
first argument
to htmlentities or htmlspecialchars, the object is apparently not always
(maybe
never?) cast to string before being pushed on the stack.
In some cases this will cause php to erronously output that the function
requires
parameter 2 to be long, unknown given. This seems to be an error from
the
underlying C function?
Sadly, I cannot provide a test script to reproduce the behaviour, but it
should be
easy enough to check whether my theory is correct.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53109&edit=1
Thread (5 messages)