-
Notifications
You must be signed in to change notification settings - Fork 348
Preserve already escaped attributes values to prevent double escaping
#6351
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
Preserve already escaped attributes values to prevent double escaping
#6351
Conversation
|
Worth a mention, some JavaScript-only syntax is creeping in to your Nunjucks I've limited changes in this PR to only govuk/macros/attributes.njk but watch out for:
Depends how strict Nunjucks v4 ends up being |
|
The macro also didn't handle being called directly with a string made {{- govukAttributes(' data-attribute="Testing & more"' | safe) -}}Sadly it passes the Expected: " data-attribute=\"Testing & more\""
Received: " =\"\" d=\"\" a=\"\" t=\"\" a=\"\" -=\"\" a=\"\" t=\"\" t=\"\" r=\"\" i=\"\" b=\"\" u=\"\" t=\"\" e=\"\" ==\"\" "=\"\" T=\"\" e=\"\" s=\"\" t=\"\" i=\"\" n=\"\" g=\"\" =\"\" &=\"\" a=\"\" m=\"\" p=\"\" ;=\"\" =\"\" m=\"\" o=\"\" r=\"\" e=\"\" "=\"\""That's all fixed now too and tests updated |
|
@colinrotherham Would you be willing to change the target of this to |
28720bb to
5588006
Compare
|
@owenatgov Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks grand 👍🏻 Thanks for this @colinrotherham
One pithy thing is that this needs a fix changelog entry. After that I'll approve.
Finally this just needs a second review. I'll ping the other devs as reviewers on ths.
attributes values to prevent double escaping
|
Good job I know you, thanks @owenatgov Changelog entry pushed |
domoscargin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
This PR closes #4940 and fixes
safeandescapefiltered values ingovukAttributes()The previous fix in #4938 missed that
JSON.stringify()inrenderMacro()is what breaks instanceof checksWe can now use the Nunjucks
is escapedtest instead of onlyis mapping