Skip to content

Conversation

Escape user data for HTML attributes to prevent XSS. This is already done in the second code snippet below.
@carsonbot carsonbot added this to the 6.4 milestone Sep 24, 2025
@carsonbot carsonbot changed the title Escape user data in server-data.rst Escape user data in server-data.rst Sep 24, 2025
@javiereguiluz javiereguiluz merged commit e3bf421 into symfony:6.4 Sep 25, 2025
3 checks passed
@javiereguiluz
Copy link
Member

Very nice catch Dave! Thanks for fixing this.

Please note that while merging we did this minor tweak:

-data-user="{{ app.user|serialize(format = 'json')|e('html_attr') }}" +data-user="{{ app.user|serialize(format = 'json')|e('html') }}"

This is what Twig recommends, for performance reasons, to use for escaping HTML attributes: https://twig.symfony.com/doc/3.x/filters/escape.html

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment