Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix double escaping in stimulus DTOs when using toArray() in combination with form methods #202

Conversation

jeroennoten
Copy link
Contributor

This fixes a double-escaping bug when the toArray() methods are used in combination with the form_ functions, as described in the README.

toArray() should return an array with non-escaped attribute key-value pairs, because they will be escaped when printed.

Therefore, I moved the escaping of the values to the toString() methods and I added some additional tests for the DTO classes to verify the change.

This additionally fixes a missed escape for the data-[controller]-[key]-class attribute values.

…ion with form methods

toArray() should return an array with non-escaped attribute key-value pairs, because
they will be escaped when printed.
Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's really nice. It makes sense: the __toString() will give you the escaped version. But toArray() will give you the non-escaped version, and then it's up to you to render it correctly.

@weaverryan
Copy link
Member

Excellent PR Jeroen!

@weaverryan weaverryan merged commit 1862d71 into symfony:main Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants