Skip to content

Feature/email disallow links - #756

Open
joeyamst wants to merge 5 commits into
mainfrom
feature/email-disallow-links
Open

Feature/email disallow links#756
joeyamst wants to merge 5 commits into
mainfrom
feature/email-disallow-links

Conversation

@joeyamst

Copy link
Copy Markdown
Contributor

Meldingen

Ticket: SIG-1234

Before opening a pull request, please ensure your branch is based on main and targets main.

Check requirements when they are met (strikethrough when not applicable):

  • Linters and Static Analysis tools have passed
  • Has tests with 100% coverage on new code (if feasible) and all test should pass
  • Scenario tests have been added/updated (if applicable)
  • Test coverage percentage threshold still passes
  • Documentation and Swagger have been updated
  • All other Required PR checks have passed

Be kind to code reviewers, please try to keep pull requests as small and focused as possible :)

Copilot AI lite review requested due to automatic review settings August 19, 2026 10:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens email content handling by preventing untrusted markdown (especially links) from being introduced into outbound emails, and by validating link schemes in backoffice-authored email bodies before they reach the mail preview/sending renderer.

Changes:

  • Escapes reporter-provided text before inserting it into markdown email templates to prevent link/HTML injection in confirmation mails.
  • Adds a markdown link-scheme validator and applies it to backoffice mail preview and “complete melding” inputs, allowlisting only http, https, mailto, and tel.
  • Expands test coverage around escaping and scheme validation, plus adds an API test ensuring disallowed schemes are rejected with 422.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
meldingen/markdown.py Adds escaping for link/image/HTML-tag constructs and introduces a link-scheme validator over markdown tokens.
meldingen/schemas/input.py Introduces allowlisted mail link schemes and validates mail body fields via AfterValidator.
meldingen/mail.py Escapes reporter text before interpolating it into markdown mail templates.
tests/test_markdown.py Adds tests for escaping behavior and link-scheme validation.
tests/test_mail.py Adds a confirmation-mail regression test ensuring reporter text cannot create links.
tests/test_input_schemas.py Adds schema-level validation tests for allowed vs disallowed link schemes in mail bodies.
tests/api/v1/endpoints/test_mail.py Adds endpoint-level test asserting 422 on disallowed link schemes in preview mail body.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread meldingen/markdown.py
Comment thread tests/test_markdown.py
Comment on lines +41 to +43
def render_permissively(text: str) -> str:
html: str = PermissiveMarkdownIt("commonmark").render(text)
return html
Comment thread tests/test_markdown.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants