From 7974d229129089a277e9ef589abcfd2b2b639b8a Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Tue, 10 Nov 2026 15:31:49 +0100 Subject: [PATCH] Contact-mail: vervolg op review (notitie weg, tekstdeel ingesprongen, nieuwe Core-tests voor details en Reply-To) Co-Authored-By: Claude Sonnet 5.5 --- .../cms-u5-contact-mail/code/summary.md | 5 + .../Email/EmailRulesAndRendererTests.cs | 106 ++++++++++++++++++ .../Email/MailTemplateRenderer.cs | 15 ++- 3 files changed, 122 insertions(+), 4 deletions(-) diff --git a/aidlc-docs/features/contact-forms-module/construction/cms-u5-contact-mail/code/summary.md b/aidlc-docs/features/contact-forms-module/construction/cms-u5-contact-mail/code/summary.md index d80dfdc..cb0060f 100644 --- a/aidlc-docs/features/contact-forms-module/construction/cms-u5-contact-mail/code/summary.md +++ b/aidlc-docs/features/contact-forms-module/construction/cms-u5-contact-mail/code/summary.md @@ -21,3 +21,8 @@ ## Found by the real-database pipeline test `datetime` drops fractions, which made the claim's concurrency check fail on the outcome save; claim time is now truncated to whole seconds. + +## Follow-up (review by AndreaSlopFotografie) +- The "you can reply directly" note is removed from the ContactMessage catalog (Reply-To may be left out when the visitor address is invalid). +- Plain text: every line of a visitor value is indented two spaces, so a visitor's own `--` line or fake headings cannot imitate the layout. +- NEW Core tests (next to the unchanged existing ones): `ContactMessageMailRenderingTests` (encoding of script/quotes/line breaks, labels encoded, null/empty Details give no block, fixed subject, text indent, no reply hint) and `SmtpReplyToTests` (valid Reply-To with name, invalid/CRLF address left out, control characters in the name dropped, none when absent), using the existing in-process stub SMTP server. Core: 639 green (625 existing + 14 new). diff --git a/src/SlpModularCms.Core.Tests/Email/EmailRulesAndRendererTests.cs b/src/SlpModularCms.Core.Tests/Email/EmailRulesAndRendererTests.cs index 7fe0edf..0697e30 100644 --- a/src/SlpModularCms.Core.Tests/Email/EmailRulesAndRendererTests.cs +++ b/src/SlpModularCms.Core.Tests/Email/EmailRulesAndRendererTests.cs @@ -479,3 +479,109 @@ public class MailPropertyTests(ITestOutputHelper output) return value == token; }); } + +/// NEW tests for the contact-message mail (details block, text part); the existing tests above are unchanged. +public class ContactMessageMailRenderingTests +{ + private readonly MailTemplateRenderer _renderer = new(); + + private static MailModel Model(params MailDetail[]? details) => new("De Site", Details: details); + + [Fact] + public void Details_AreHtmlEncoded_BeforeLineBreaksBecomeBr() + { + var mail = _renderer.Render(MailKind.ContactMessage, "nl", + Model(new MailDetail("Bericht", " & 'q'\r\nregel2\nregel3"))); + + mail.Html.Should().NotContain("