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, "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)
}
}