note 116535 added to function.htmlspecialchars-decode
| From: | patrice dot leblanc dot pro at gmail dot com | Date: | Mon, 19 Jan 2015 20:50:42 +0000 |
| Subject: | note 116535 added to function.htmlspecialchars-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201462@lists.php.net to get a copy of this message | ||
For the famous problem of '&'...
I was disturbed with pinkgothic at gmail dot com but i wanted to find why. (...noob ^^)
In fact, if 'encode()' is on the setter, the object will be created, and encoded before to
be registered. (expected behavior, at the beginning)
But, when you take/create the object from the database, it will be encoded again ! (and
'decode()' resolve this stuff... ^^)
If you print your String on the screen, there will be two ways :
1) Your object is encoded twice (because it comes from database) :
You NEED to 'decode()', only once, to print it on screen.
Warning : if you 'decode()' twice, XSS is open.
2) Your object is encoded once (because it is'nt an object from database)
You DON'T NEED to 'decode()', the browser will translate and print it on the screen
(it's his job).
However, depending of the origin of your object, it will be different !
An 'encoded()' from your code, and an 'encoded(encoded())' from the manager,
then, the comparisons will be problematic...
... unless you work ONLY with objects from database... even if you have just created one, you will
have to recover it with your manager. And then, you will decode() all of them to print them on the
screen.
Please mail me if i'm wrong.
Sorry for my poor english. (... French noob ^^)
----
Server IP: 72.52.91.14
Probable Submitter: 78.204.141.55
----
Manual Page -- http://php.net/manual/en/function.htmlspecialchars-decode.php
Edit -- https://master.php.net/note/edit/116535
Del: integrated -- https://master.php.net/note/delete/116535/integrated
Del: useless -- https://master.php.net/note/delete/116535/useless
Del: bad code -- https://master.php.net/note/delete/116535/bad+code
Del: spam -- https://master.php.net/note/delete/116535/spam
Del: non-english -- https://master.php.net/note/delete/116535/non-english
Del: in docs -- https://master.php.net/note/delete/116535/in+docs
Del: other reasons-- https://master.php.net/note/delete/116535
Reject -- https://master.php.net/note/reject/116535
Search -- https://master.php.net/manage/user-notes.php