I have a form that contains html entities in an input field, something like:
<input type="hidden" name="foo" value="<?php htmlspecialchars($foo) ?>" />
If $foo
takes in the value of something like "<b>foo</b>
", it seems that when the form is posted to the PHP script, the value of $_POST['foo']
is already decoded...so does that mean I don't need to use htmlspecialchars_decode
to convert $_POST['foo']
back to its original form $foo
?
Thanks for any inputs on this issue.
$foo
is suddenly" onclick="maliciuos code"
you have a problem, that's why you encode to entities, to avoid XSS. – adeneo