govuk-frontend-jinja icon indicating copy to clipboard operation
govuk-frontend-jinja copied to clipboard

Templates use lower filter on values where it should not

Open tim-s-ccs opened this issue 10 months ago • 1 comments

Describe the bug Within some of the templates the lower filter is used where it should not be. The affect components are:

  • Exit this page
  • Select

In the "Exist this page" component, the lower filter is being applied to the attributes tag:

{{ attribute }}="{{ value | lower }}"{% endfor %}

As the user passes in the attributes we should not mutate what they are otherwise there could be unexpected consequences. I realises this was required to pass a test but perhaps the test needs to be updated (can be extended as part of my work in https://github.com/LandRegistry/govuk-frontend-jinja/pull/81)

In the "Select" component, the lower filter is being applied to the value:

<option {%- if item.value is not undefined %} value="{{ item.value | lower }}"{% endif %}

Again, as the user passes in the values we should not mutate them are otherwise there could be unexpected consequences (which is how I discovered this bug).

Expected behavior

  • The "Exit this page" component should not lower the attributes passed by the user
  • The "Subject" component should not lower the values passed by the user

Additional context I'm happy to help and contribute to this project so if you want to make changes I can

tim-s-ccs avatar Apr 17 '24 11:04 tim-s-ccs