diff --git a/src/openforms/emails/tests/test_confirmation_email.py b/src/openforms/emails/tests/test_confirmation_email.py index 34f18a53f0..c6f0028c0d 100644 --- a/src/openforms/emails/tests/test_confirmation_email.py +++ b/src/openforms/emails/tests/test_confirmation_email.py @@ -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", diff --git a/src/openforms/formio/formatters/formio.py b/src/openforms/formio/formatters/formio.py index 4069e1e23f..b0b29b28a0 100644 --- a/src/openforms/formio/formatters/formio.py +++ b/src/openforms/formio/formatters/formio.py @@ -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)