Skip to content

Commit 9bb49a3

Browse files
committed
Update EmailContentBuilderTests.cs
1 parent 0c305c1 commit 9bb49a3

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

tests/web/Jordnaer.Tests/Features/Email/EmailContentBuilderTests.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,27 @@ public void GenericNotification_ShouldHtmlEncode_TitleAndDescription()
252252
// Act
253253
var result = EmailContentBuilder.GenericNotification(title, description, null, BaseUrl);
254254

255-
// Assert
256-
result.Should().NotContain("<script>");
257-
result.Should().Contain("&lt;script&gt;");
255+
// Assert - raw title must not appear; its fully HTML-encoded form must appear
256+
result.Should().NotContain(title);
257+
result.Should().Contain("&lt;script&gt;alert('xss')&lt;/script&gt;");
258258
result.Should().Contain("Malicious &amp; &lt;content&gt;");
259259
}
260260

261+
[Fact]
262+
public void GenericNotification_ShouldResolveRelativeUrl_WhenBaseUrlIsNull()
263+
{
264+
// Arrange
265+
var title = "Test notification";
266+
var description = "Test description";
267+
var linkUrl = "/some-path";
268+
269+
// Act - baseUrl is null; linkUrl is relative, so the fallback base should be used
270+
var result = EmailContentBuilder.GenericNotification(title, description, linkUrl, null);
271+
272+
// Assert - relative linkUrl should be resolved against the hardcoded fallback base
273+
result.Should().Contain("https://mini-moeder.dk/some-path");
274+
}
275+
261276
[Fact]
262277
public void GroupInvite_ShouldHtmlEncode_InviterName()
263278
{

0 commit comments

Comments
 (0)