package mailhtml import ( "strings" "testing" ) func TestSanitizeRemovesWarmblyOpenPixels(t *testing.T) { const id = "550e8400-e29b-41d4-a716-446655440000" for _, markup := range []string{ ``, `

Quoted reply

`, ``, ``, ``, ``, } { t.Run(markup, func(t *testing.T) { out := Sanitize(`

Hello

` + markup) if strings.Contains(out, "Hello

") { t.Fatalf("message content lost: %s", out) } }) } } func TestSanitizeKeepsOrdinaryImagesAndLinks(t *testing.T) { const image = "https://cdn.customer.test/logo.png" const link = "https://custom.test/c/550e8400-e29b-41d4-a716-446655440000" out := Sanitize(`

café & more

` + `` + `Visit`) for _, want := range []string{image, link, "data:image/png;base64,iVBORw0KGgo=", "/t/o/logo.png", "café & more"} { if !strings.Contains(out, want) { t.Errorf("display content %q lost: %s", want, out) } } if again := Sanitize(out); again != out { t.Errorf("sanitizing twice changed the display: %s", again) } }