From 8fc127621a6f674d930cb61aed92499b648fd492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Such=C3=A1nek?= Date: Thu, 3 Dec 2026 10:57:00 +0100 Subject: [PATCH] feat(mailer): Project email invitation and escaping in HTML mails --- packages/dsw-mailer/CHANGELOG.md | 7 ++ .../templates/_common/footer.html.j2 | 2 +- .../templates/_common/layout.html.j2 | 2 +- .../registrationConfirmation/message.html.j2 | 4 +- .../registry/resetPassword/message.html.j2 | 4 +- .../wizard/apiKeyCreated/message.html.j2 | 8 +- .../wizard/apiKeyExpiration/message.html.j2 | 8 +- .../commentThreadAssigned/message.html.j2 | 16 +-- .../wizard/emailChange/message.html.j2 | 6 +- .../projectEmailInvitation/message.html.j2 | 101 ++++++++++++++++++ .../projectEmailInvitation/message.json | 16 +++ .../projectEmailInvitation/message.txt.j2 | 16 +++ .../projectEmailInvitation/subject.txt.j2 | 1 + .../wizard/projectInvitation/message.html.j2 | 12 +-- .../registrationConfirmation/message.html.j2 | 6 +- .../wizard/resetPassword/message.html.j2 | 6 +- .../wizard/twoFactorAuth/message.html.j2 | 6 +- packages/dsw-mailer/tests/test_mailer.py | 61 ++++++++++- 18 files changed, 241 insertions(+), 41 deletions(-) create mode 100644 packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.html.j2 create mode 100644 packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.json create mode 100644 packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.txt.j2 create mode 100644 packages/dsw-mailer/templates/wizard/projectEmailInvitation/subject.txt.j2 diff --git a/packages/dsw-mailer/CHANGELOG.md b/packages/dsw-mailer/CHANGELOG.md index 93df54ff..6c036389 100644 --- a/packages/dsw-mailer/CHANGELOG.md +++ b/packages/dsw-mailer/CHANGELOG.md @@ -7,6 +7,13 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + +- The Wizard's `projectEmailInvitation` template, with a link to `/project-invitations/`, for people invited to a project by email + +### Fixed + +- The HTML part of the built-in templates escapes the text entered by users, such as names, project names and comments ## [5.1.0] diff --git a/packages/dsw-mailer/templates/_common/footer.html.j2 b/packages/dsw-mailer/templates/_common/footer.html.j2 index d8c2653b..347e426a 100644 --- a/packages/dsw-mailer/templates/_common/footer.html.j2 +++ b/packages/dsw-mailer/templates/_common/footer.html.j2 @@ -156,7 +156,7 @@

{% if ctx.appTitle and ctx.clientUrl %} - {% trans %}This email was generated from{% endtrans %} {{ ctx.appTitle }}. + {% trans %}This email was generated from{% endtrans %} {{ ctx.appTitle|e }}.
{% endif %} diff --git a/packages/dsw-mailer/templates/_common/layout.html.j2 b/packages/dsw-mailer/templates/_common/layout.html.j2 index b9cd037e..b82d58c9 100644 --- a/packages/dsw-mailer/templates/_common/layout.html.j2 +++ b/packages/dsw-mailer/templates/_common/layout.html.j2 @@ -13,7 +13,7 @@ - {{ ctx.subject }} + {{ ctx.subject|e }} diff --git a/packages/dsw-mailer/templates/registry/registrationConfirmation/message.html.j2 b/packages/dsw-mailer/templates/registry/registrationConfirmation/message.html.j2 index 9f9359c8..f5b26ddb 100644 --- a/packages/dsw-mailer/templates/registry/registrationConfirmation/message.html.j2 +++ b/packages/dsw-mailer/templates/registry/registrationConfirmation/message.html.j2 @@ -1,7 +1,7 @@ {% extends '_common/layout.html.j2' %} {%- set url = ctx.clientUrl ~ "/signup/" ~ ctx.userUuid ~ "/" ~ ctx.hash -%} -{%- set userFirstName = ctx.userFirstName -%} +{%- set userFirstName = ctx.userFirstName|e -%} {% block body %} @@ -73,7 +73,7 @@ diff --git a/packages/dsw-mailer/templates/registry/resetPassword/message.html.j2 b/packages/dsw-mailer/templates/registry/resetPassword/message.html.j2 index 23d8671f..3852cb97 100644 --- a/packages/dsw-mailer/templates/registry/resetPassword/message.html.j2 +++ b/packages/dsw-mailer/templates/registry/resetPassword/message.html.j2 @@ -1,7 +1,7 @@ {% extends '_common/layout.html.j2' %} {%- set url = ctx.clientUrl ~ "/forgotten-password/" ~ ctx.userUuid ~ "/" ~ ctx.hash -%} -{%- set userFirstName = ctx.userFirstName -%} +{%- set userFirstName = ctx.userFirstName|e -%} {% block body %}

{% trans %}Thank you for using DSW!{% endtrans %}

- {% if ctx.appTitle %}{{ ctx.appTitle }} {% trans %}team{% endtrans %}{% endif %} + {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %}

@@ -73,7 +73,7 @@ diff --git a/packages/dsw-mailer/templates/wizard/apiKeyCreated/message.html.j2 b/packages/dsw-mailer/templates/wizard/apiKeyCreated/message.html.j2 index 2e7f84f2..b09c65b0 100644 --- a/packages/dsw-mailer/templates/wizard/apiKeyCreated/message.html.j2 +++ b/packages/dsw-mailer/templates/wizard/apiKeyCreated/message.html.j2 @@ -1,7 +1,7 @@ {% extends '_common/layout.html.j2' %} -{%- set userFirstName = ctx.userFirstName -%} -{%- set tokenName = "" ~ ctx.tokenName ~ "" -%} +{%- set userFirstName = ctx.userFirstName|e -%} +{%- set tokenName = "" ~ ctx.tokenName|e ~ "" -%} {%- set tokenExpirationDate = ctx.tokenExpiresAt|datetime_format("%d/%m/%Y") -%} {%- set tokenExpirationTime = ctx.tokenExpiresAt|datetime_format("%H:%M (%Z)") -%} @@ -76,10 +76,10 @@ diff --git a/packages/dsw-mailer/templates/wizard/apiKeyExpiration/message.html.j2 b/packages/dsw-mailer/templates/wizard/apiKeyExpiration/message.html.j2 index 71696624..8151d463 100644 --- a/packages/dsw-mailer/templates/wizard/apiKeyExpiration/message.html.j2 +++ b/packages/dsw-mailer/templates/wizard/apiKeyExpiration/message.html.j2 @@ -1,7 +1,7 @@ {% extends '_common/layout.html.j2' %} -{%- set userFirstName = ctx.userFirstName -%} -{%- set tokenName = "" ~ ctx.tokenName ~ "" -%} +{%- set userFirstName = ctx.userFirstName|e -%} +{%- set tokenName = "" ~ ctx.tokenName|e ~ "" -%} {%- set tokenExpirationDate = ctx.tokenExpiresAt|datetime_format("%d/%m/%Y") -%} {%- set tokenExpirationTime = ctx.tokenExpiresAt|datetime_format("%H:%M (%Z)") -%} @@ -74,10 +74,10 @@ diff --git a/packages/dsw-mailer/templates/wizard/commentThreadAssigned/message.html.j2 b/packages/dsw-mailer/templates/wizard/commentThreadAssigned/message.html.j2 index 1c7e6361..9d8862f0 100644 --- a/packages/dsw-mailer/templates/wizard/commentThreadAssigned/message.html.j2 +++ b/packages/dsw-mailer/templates/wizard/commentThreadAssigned/message.html.j2 @@ -8,7 +8,7 @@ {%- macro projectLink(projectUuid) -%} {{ ctx.clientUrl }}/projects/{{ projectUuid }} {%- endmacro -%} -{%- set userFirstName = ctx.userFirstName -%} +{%- set userFirstName = ctx.userFirstName|e -%} {% block body %}

{% trans %}Thank you for using DSW!{% endtrans %}

- {% if ctx.appTitle %}{{ ctx.appTitle }} {% trans %}team{% endtrans %}{% endif %} + {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %}

{% if ctx.supportEmail %} - {% trans %}If you did not initiate this action, please contact us via{% endtrans %} {{ ctx.supportEmail }}. + {% trans %}If you did not initiate this action, please contact us via{% endtrans %} {{ ctx.supportEmail|e }}. {% endif %}

{% trans %}Thank you for using DSW!{% endtrans %}

- {% if ctx.appTitle %}{{ ctx.appTitle }} {% trans %}team{% endtrans %}{% endif %} + {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %}

{% if ctx.supportEmail %} - {% trans %}If you encounter any issues, please contact us via{% endtrans %} {{ ctx.supportEmail }}. + {% trans %}If you encounter any issues, please contact us via{% endtrans %} {{ ctx.supportEmail|e }}. {% endif %}

{% trans %}Thank you for using DSW!{% endtrans %}

- {% if ctx.appTitle %}{{ ctx.appTitle }} {% trans %}team{% endtrans %}{% endif %} + {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %}

@@ -58,7 +58,7 @@

- {{ items[0].projectName }} + {{ items[0].projectName|e }}

{% for item in items %} @@ -66,21 +66,21 @@

- {{ item.text|no_markdown|truncate(140, False, '...') }} + {{ item.text|no_markdown|truncate(140, False, '...')|replace('<', '<') }}

{% if item.questionTitle %}

- {% trans %}Question{% endtrans %}: {{ item.questionTitle }} + {% trans %}Question{% endtrans %}: {{ item.questionTitle|e }}

{% endif %} @@ -118,10 +118,10 @@ {% trans %}View all comment threads assigned to you{% endtrans %}


{% if ctx.supportEmail %} - {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail }}.

+ {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail|e }}.

{% endif %} {% trans %}Thank you for using DSW!{% endtrans %}

- {% if ctx.appTitle %}{{ ctx.appTitle }} {% trans %}team{% endtrans %}{% endif %} + {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %}

diff --git a/packages/dsw-mailer/templates/wizard/emailChange/message.html.j2 b/packages/dsw-mailer/templates/wizard/emailChange/message.html.j2 index e3c4dcb2..4c409f0a 100644 --- a/packages/dsw-mailer/templates/wizard/emailChange/message.html.j2 +++ b/packages/dsw-mailer/templates/wizard/emailChange/message.html.j2 @@ -1,6 +1,6 @@ {% extends '_common/layout.html.j2' %} -{%- set userFirstName = ctx.userFirstName -%} +{%- set userFirstName = ctx.userFirstName|e -%} {% block body %}
- {% trans %}Assigned by{% endtrans %} {{ item.assignedBy.firstName }} {{ item.assignedBy.lastName }} + {% trans %}Assigned by{% endtrans %} {{ item.assignedBy.firstName|e }} {{ item.assignedBy.lastName|e }} - {% trans %}Open{% endtrans %} + {% trans %}Open{% endtrans %}
@@ -74,10 +74,10 @@

{% trans %}In case you did not request this change, you can safely ignore this email.{% endtrans %}

{% if ctx.supportEmail %} - {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail }}.

+ {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail|e }}.

{% endif %} {% trans %}Thank you for using DSW!{% endtrans %}

- {% if ctx.appTitle %}{{ ctx.appTitle }} {% trans %}team{% endtrans %}{% endif %} + {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %}

diff --git a/packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.html.j2 b/packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.html.j2 new file mode 100644 index 00000000..79fea675 --- /dev/null +++ b/packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.html.j2 @@ -0,0 +1,101 @@ +{% extends '_common/layout.html.j2' %} + +{#- Autoescaping is off and this goes to any address: escape what users enter -#} +{%- set ownerFirstName = ctx.ownerFirstName|e -%} +{%- set ownerLastName = ctx.ownerLastName|e -%} +{%- set projectName = "\"" ~ ctx.projectName|e ~ "\"" -%} +{%- set roleName = "\"" ~ ctx.roleName|e ~ "\"" -%} + +{% block body %} +
+ + + + + +
+ + + + + + + + +
+

+ {% trans %}Hello{% endtrans %},

+ {% trans %}{{ ownerFirstName }} {{ ownerLastName }} has invited you to the project {{ projectName }} with the role {{ roleName }}{% endtrans %}. +

+
+ + +
+ + + + + + +
+ + + + + + +
+ {% trans %}Open invitation{% endtrans %} +
+
+ + + + + + +
+ + + + + + + + +
+

+ {% trans %}Open the link to log in or create an account.{% endtrans %} {% trans count=ctx.expirationDays %}The invitation expires in {{ count }} day.{% pluralize %}The invitation expires in {{ count }} days.{% endtrans %}

+ {% trans %}If you don't know the sender or weren't expecting this invitation, you can ignore this email.{% endtrans %}

+ {% if ctx.supportEmail %} + {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail|e }}.

+ {% endif %} + {% trans %}Thank you for using DSW!{% endtrans %}

+ {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %} +

+
+ + +
+{% endblock %} diff --git a/packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.json b/packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.json new file mode 100644 index 00000000..df88ed38 --- /dev/null +++ b/packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.json @@ -0,0 +1,16 @@ +{ + "id": "wizard:projectEmailInvitation", + "subject": "Project Invitation", + "subjectPrefix": true, + "defaultSenderName": "DSW", + "parts": [ + { + "type": "html", + "file": "message.html.j2" + }, + { + "type": "plain", + "file": "message.txt.j2" + } + ] +} diff --git a/packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.txt.j2 b/packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.txt.j2 new file mode 100644 index 00000000..b8503e54 --- /dev/null +++ b/packages/dsw-mailer/templates/wizard/projectEmailInvitation/message.txt.j2 @@ -0,0 +1,16 @@ +{%- set ownerFirstName = ctx.ownerFirstName -%} +{%- set ownerLastName = ctx.ownerLastName -%} +{%- set projectName = "\"" ~ ctx.projectName ~ "\"" -%} +{%- set roleName = "\"" ~ ctx.roleName ~ "\"" -%} + +{% trans %}Hello{% endtrans %}, + +{% trans %}{{ ownerFirstName }} {{ ownerLastName }} has invited you to the project {{ projectName }} with the role {{ roleName }}{% endtrans %}: + +{{ ctx.clientUrl }}/project-invitations/{{ ctx.invitationHash }} + +{% trans %}Open the link to log in or create an account.{% endtrans %} {% trans count=ctx.expirationDays %}The invitation expires in {{ count }} day.{% pluralize %}The invitation expires in {{ count }} days.{% endtrans %} + +{% trans %}If you don't know the sender or weren't expecting this invitation, you can ignore this email.{% endtrans %} + +{% include '_common/footer.txt.j2' %} diff --git a/packages/dsw-mailer/templates/wizard/projectEmailInvitation/subject.txt.j2 b/packages/dsw-mailer/templates/wizard/projectEmailInvitation/subject.txt.j2 new file mode 100644 index 00000000..fa75e3b6 --- /dev/null +++ b/packages/dsw-mailer/templates/wizard/projectEmailInvitation/subject.txt.j2 @@ -0,0 +1 @@ +{% trans %}Project Invitation{% endtrans %} diff --git a/packages/dsw-mailer/templates/wizard/projectInvitation/message.html.j2 b/packages/dsw-mailer/templates/wizard/projectInvitation/message.html.j2 index d513fe74..540495b3 100644 --- a/packages/dsw-mailer/templates/wizard/projectInvitation/message.html.j2 +++ b/packages/dsw-mailer/templates/wizard/projectInvitation/message.html.j2 @@ -1,9 +1,9 @@ {% extends '_common/layout.html.j2' %} -{%- set userFirstName = ctx.inviteeFirstName -%} -{%- set ownerFirstName = ctx.ownerFirstName -%} -{%- set ownerLastName = ctx.ownerLastName -%} -{%- set projectName = "" ~ ctx.projectName ~ "" -%} +{%- set userFirstName = ctx.inviteeFirstName|e -%} +{%- set ownerFirstName = ctx.ownerFirstName|e -%} +{%- set ownerLastName = ctx.ownerLastName|e -%} +{%- set projectName = "" ~ ctx.projectName|e ~ "" -%} {% block body %} @@ -75,10 +75,10 @@ diff --git a/packages/dsw-mailer/templates/wizard/registrationConfirmation/message.html.j2 b/packages/dsw-mailer/templates/wizard/registrationConfirmation/message.html.j2 index 0b45cd78..4b9cd540 100644 --- a/packages/dsw-mailer/templates/wizard/registrationConfirmation/message.html.j2 +++ b/packages/dsw-mailer/templates/wizard/registrationConfirmation/message.html.j2 @@ -1,6 +1,6 @@ {% extends '_common/layout.html.j2' %} -{%- set userFirstName = ctx.userFirstName -%} +{%- set userFirstName = ctx.userFirstName|e -%} {% block body %}

{% if ctx.supportEmail %} - {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail }}.

+ {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail|e }}.

{% endif %} {% trans %}Thank you for using DSW!{% endtrans %}

- {% if ctx.appTitle %}{{ ctx.appTitle }} {% trans %}team{% endtrans %}{% endif %} + {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %}

@@ -73,10 +73,10 @@ diff --git a/packages/dsw-mailer/templates/wizard/resetPassword/message.html.j2 b/packages/dsw-mailer/templates/wizard/resetPassword/message.html.j2 index a2245440..1799ce3e 100644 --- a/packages/dsw-mailer/templates/wizard/resetPassword/message.html.j2 +++ b/packages/dsw-mailer/templates/wizard/resetPassword/message.html.j2 @@ -1,6 +1,6 @@ {% extends '_common/layout.html.j2' %} -{%- set userFirstName = ctx.userFirstName -%} +{%- set userFirstName = ctx.userFirstName|e -%} {% block body %}

{% if ctx.supportEmail %} - {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail }}.

+ {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail|e }}.

{% endif %} {% trans %}Thank you for using DSW!{% endtrans %}

- {% if ctx.appTitle %}{{ ctx.appTitle }} {% trans %}team{% endtrans %}{% endif %} + {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %}

@@ -72,10 +72,10 @@ diff --git a/packages/dsw-mailer/templates/wizard/twoFactorAuth/message.html.j2 b/packages/dsw-mailer/templates/wizard/twoFactorAuth/message.html.j2 index bf3e0f9f..2afaddeb 100644 --- a/packages/dsw-mailer/templates/wizard/twoFactorAuth/message.html.j2 +++ b/packages/dsw-mailer/templates/wizard/twoFactorAuth/message.html.j2 @@ -1,6 +1,6 @@ {% extends '_common/layout.html.j2' %} -{%- set userFirstName = ctx.userFirstName -%} +{%- set userFirstName = ctx.userFirstName|e -%} {% block body %}

{% if ctx.supportEmail %} - {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail }}.

+ {% trans %}If any problem occurs contact us via{% endtrans %} {{ ctx.supportEmail|e }}.

{% endif %} {% trans %}Thank you for using DSW!{% endtrans %}

- {% if ctx.appTitle %}{{ ctx.appTitle }} {% trans %}team{% endtrans %}{% endif %} + {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %}

@@ -71,10 +71,10 @@ {% trans %}This code is valid for{% endtrans %} {{ ctx.clientUrl }}. {% if ctx.supportEmail %}

- {% trans %}If you did not initiate this login attempt, please contact us via{% endtrans %} {{ ctx.supportEmail }}. + {% trans %}If you did not initiate this login attempt, please contact us via{% endtrans %} {{ ctx.supportEmail|e }}. {% endif %}

{% trans %}Thank you for using DSW!{% endtrans %}

- {% if ctx.appTitle %}{{ ctx.appTitle }} {% trans %}team{% endtrans %}{% endif %} + {% if ctx.appTitle %}{{ ctx.appTitle|e }} {% trans %}team{% endtrans %}{% endif %}

diff --git a/packages/dsw-mailer/tests/test_mailer.py b/packages/dsw-mailer/tests/test_mailer.py index 6473e862..66db1e03 100644 --- a/packages/dsw-mailer/tests/test_mailer.py +++ b/packages/dsw-mailer/tests/test_mailer.py @@ -10,7 +10,7 @@ from dsw.mailer.mailer import Mailer, MailerCommand from dsw.mailer.templates import TemplateRegistry -from conftest import TENANT, mail_locale, po_bytes, ui_locale +from conftest import TEMPLATES_DIR, TENANT, mail_locale, po_bytes, ui_locale def command(recipients: list[dict], **body) -> PersistentCommand: @@ -108,6 +108,65 @@ def test_render_registry_template(tmp_path, tenant, context, template, path, sub assert subject in message.subject +@pytest.mark.parametrize(('days', 'expiry'), [(1, 'in 1 day.'), (14, 'in 14 days.')]) +def test_render_project_email_invitation(tmp_path, tenant, context, days, expiry): + # the parameters are those of the backend's mailer + templates = TemplateRegistry(cfg=types.SimpleNamespace(), workdir=context.app.workdir) + rq = requests_for(tmp_path, command( + [{'uuid': None, 'email': 'john@example.org'}], template='projectEmailInvitation', + parameters={'clientUrl': 'https://wizard.example.org', 'appTitle': None, + 'projectUuid': 'project-1', 'projectName': 'P', + 'ownerFirstName': 'Jane', 'ownerLastName': 'Doe', + 'roleName': 'Editor', 'invitationHash': 'abc', 'expirationDays': days}, + ))[0] + cfg = types.SimpleNamespace(name='Wizard', email='wizard@example.org') + message = templates.render(rq, cfg, gettext.NullTranslations()) + link = 'https://wizard.example.org/project-invitations/abc' + assert message.subject == 'Wizard: Project Invitation' + assert link in message.plain_body + assert f'href="{link}"' in message.html_body + assert 'to the project "P" with the role "Editor"' in message.plain_body + # what users enter is escaped in HTML + assert 'Jane <b>Doe</b> has invited you' in message.html_body + assert '"<a href="x">P</a>"' in message.html_body + assert '"Editor"' in message.html_body + for body in (message.plain_body, message.html_body): + assert f'The invitation expires {expiry}' in body + assert 'john@example.org' not in body + + +ENTERED = 'R&D' + + +@pytest.mark.parametrize(('mode', 'template'), [ + (path.parent.parent.name, path.parent.name) + for path in sorted(TEMPLATES_DIR.glob('*/*/message.json')) +]) +def test_html_escapes_what_users_enter(tmp_path, tenant, context, mode, template): + templates = TemplateRegistry(cfg=types.SimpleNamespace(), workdir=context.app.workdir) + entered = dict.fromkeys( + ('userFirstName', 'inviteeFirstName', 'ownerFirstName', 'ownerLastName', 'projectName', + 'roleName', 'tokenName', 'appTitle', 'supportEmail'), ENTERED) + notification = { + 'projectUuid': 'p', 'projectName': ENTERED, 'path': ENTERED, 'commentThreadUuid': 't', + 'questionTitle': ENTERED, 'text': 'R&D R' not in message.html_body + assert '