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

Handle special characters in rtn req. bookmarks #1394

Merged
merged 3 commits into from
Oct 10, 2024

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Oct 9, 2024

https://eaflood.atlassian.net/browse/WATER-4685

Part of the work to migrate managing return requirements from NALD to WRLS

In Add site description to rtn. req. bookmark links we added the return requirement site description to the bookmarks we display when viewing a return version with more than one requirement.

However, that change didn't account for users' adding site descriptions that include special characters, such as " & '.

When these descriptions are included in the bookmark links, they appear like this.

  • Return reference 100234 - Quantities taken between points X, Y &Z
  • Return reference 100432 - Opposite "Old cottage" entrance
  • Return reference 100567 - Borehole in 'middle' field

This change updates the logic to escape these characters.


The problem is caused because the description is being added to a non-markup object <a>. This means Nunjucks is auto-escaping the content to protect us from an XSS attack.

To tell it not to auto-escape we have to use the safe filter.

https://eaflood.atlassian.net/browse/WATER-4685

> Part of the work to migrate managing return requirements from NALD to WRLS

In [Add site description to rtn. req. bookmark links](#1358) we added the return requirement site description to the bookmarks we display when viewing a return version with more than one requirement.

However, in that change we didn't cater for the fact users have added site descriptions that include special characters, for example `& " '`.

When these descriptions are included in the bookmark links, they appear like this.

- `Return reference 100234 - Quantities taken between points X, Y &amp;Z`
- `Return reference 100432 - Opposite &quot;Old cottage&quot; entrance`
- `Return reference 100567 - Borehole in &#39;middle&#39; field`

This changes updates the logic to escape these characters.
@Cruikshanks Cruikshanks added the bug Something isn't working label Oct 9, 2024
@Cruikshanks Cruikshanks self-assigned this Oct 9, 2024
The problem is caused because the description is being added to a non-markup object `<a>`. This means Nunjucks is auto-escaping the content to protect us from an XSS attack.

To tell it not to auto-escape we have to use the [safe filter](https://mozilla.github.io/nunjucks/templating.html#autoescaping).
@Cruikshanks Cruikshanks marked this pull request as ready for review October 9, 2024 16:57
@Cruikshanks Cruikshanks merged commit 57d03a2 into main Oct 10, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the fix-handle-special-chars-rtn-req-bookmark branch October 10, 2024 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants