From the database I receive the following text:
<div onclick="alert('código inyectado');">Texto</div>
[img]http://www.hobbyconsolas.com/sites/hobbyconsolas.com/public/media/image/2015/07/503196-halo-5-guardians-nuevos-datos-campana-cooperativa.jpg[/img]
Y aquà una URL: [url]https://www.google.es/?gws_rd=ssl[/url]
Bueno pues vamos [b]a ver si esto funciona[/b] porque "todavÃa" no lo sé [i][u]bien[/u][/i]
This text is stored in a variable called $texto
. Once htmlspecialchars()
applied to the variable, I go through where I´m finding the problem:
$texto = str_replace(""","\"",$texto); //para comillas
$texto = str_replace("<","<",$texto); // para <
$texto = str_replace(">",">",$texto); // para >
But no modification is done. If I remove the character &
works, how can I fix this problem?