How can I prevent XSS when I show data from a textarea with a wyswyg editor in Symfony2?
I have a textarea with tinyMCE editor. I can insert code for bold, italic, and after I can show the data in the browser with the twig filter raw:
{{miArticulo.contenido|raw}}
But when I write script in the textarea, for example, an alert, it is rendered in the browser too;
How Can I show only secure metas from HTML? I try surround with the twig filter autoescape, but I failed:
{% autoescape 'html' %}{{miArticulo.contenido|raw}}{% endautoescape %}
Can I show secure content con twig or I should try with other libraries such as HTMLPurifier
{{miArticulo.contenido|escape('html')|raw}}? Isn't that available in Symphony2? twig.sensiolabs.org/doc/filters/escape.html - pueloescape('js')? - puelo\x3Cp\x3E\x3Cstrong\x3- Giancarlo Ventura Granadosjsescape strategy implemented in twig. Could be a bug. I think your best bet becomes implementing your own custom escape strategy. twig.sensiolabs.org/doc/filters/escape.html#custom-escapers - puelo