fixing folders and image rendering in client
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package webui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"mailgoserver/internal/mailview"
|
||||
)
|
||||
|
||||
func TestInlineContentIDImagesReplacesWithDataURI(t *testing.T) {
|
||||
html := `<p><img src="cid:img1@example.com"></p>`
|
||||
attachments := []mailview.Attachment{
|
||||
{Filename: "header.png", ContentType: "image/png", Data: []byte("fake-png-bytes"), ContentID: "img1@example.com"},
|
||||
}
|
||||
got := inlineContentIDImages(html, attachments)
|
||||
if strings.Contains(got, "cid:") {
|
||||
t.Errorf("cid: reference survived: %q", got)
|
||||
}
|
||||
if !strings.Contains(got, "data:image/png;base64,") {
|
||||
t.Errorf("expected a data: URI in %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInlineContentIDImagesLeavesUnmatchedRefsAlone(t *testing.T) {
|
||||
html := `<p><img src="cid:unknown@example.com"></p>`
|
||||
// No attachment carries this Content-Id — must not touch the src, since
|
||||
// htmlBodyPolicy.Sanitize (run right after this) already strips any src it
|
||||
// doesn't recognize, and that's the correct outcome for a genuinely missing part.
|
||||
got := inlineContentIDImages(html, nil)
|
||||
if got != html {
|
||||
t.Errorf("got %q, want unchanged", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user