I've read here:
https://stackoverflow.com/a/8932454/4301970
that htmlspecialchars() is very effective preventing xss attacks.
I'm receiving formated text from a wysiwyg editor, for example:
<p>
<em>
<strong><span style="font-size:36pt;">test</span></strong>
</em>
</p>
Encoding this on my html:
<!DOCTYPE html>
<html lang=en>
<head>
<title></title>
</head>
<body>
<?php echo htmlspecialchars('<p><em><strong><span style="font-size:36pt;">test</span></strong></em></p>', ENT_QUOTES); ?>
</body>
</html>
Will output on browser:
<p><em><strong><span style="font-size:36pt;">test</span></strong></em></p>
How can I display the formatted text correctly, while preventing XSS injections?