Skip to content

Commit

Permalink
Merge pull request #4987 from open-formulieren/issue/4978-fix-escaped…
Browse files Browse the repository at this point in the history
…-html-in-pdf

🐛 [#4978] Fix accidental HTML escaping in summary PDF/confirmatio…
  • Loading branch information
sergei-maertens authored Jan 6, 2025
2 parents 105dcdf + f36da6f commit 933bc44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/openforms/emails/tests/test_confirmation_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ def test_attachment(self):
self.assertTagWithTextIn("td", "Last name", rendered_content)
self.assertTagWithTextIn("td", "Doe", rendered_content)
self.assertTagWithTextIn("td", "File", rendered_content)
self.assertTagWithTextIn(
"td", _("attachment: %s") % "my-image.jpg", rendered_content
)
self.assertTagWithTextIn("td", "my-image.jpg", rendered_content)

@patch(
"openforms.emails.templatetags.appointments.get_plugin",
Expand Down
10 changes: 7 additions & 3 deletions src/openforms/formio/formatters/formio.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ def normalise_value_to_list(self, component: Component, value: Any):
return value

def process_result(self, component: Component, formatted: str) -> str:
# prefix joined filenames to match legacy
if formatted:
if not formatted:
return ""

# Make sure we don't mangle safe-strings!
if self.as_html:
return formatted
else:
return _("attachment: %s") % formatted
return formatted

def format(self, component: Component, value: dict) -> str:
# this is only valid for display to the user (because filename component option, dedupe etc)
Expand Down

0 comments on commit 933bc44

Please sign in to comment.