Revert "plugins/viewhtml: convert mailto links"

This reverts commit 02faf6174b.

This commit doesn't work, because it's applied to <img> tags. Making it
handle <a> tags doesn't work either because bluemonday will strip any
target="_blank" attributes, making the compose form open in the
<iframe>. Let's just revert this whole commit for now.
This commit is contained in:
Simon Ser 2020-02-25 15:37:47 +01:00
parent 3cfd0b942b
commit 8c4fd20e27
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 9 additions and 32 deletions

View file

@ -431,7 +431,6 @@ func handleCompose(ctx *koushin.Context, msg *OutgoingMessage, draft *messagePat
func handleComposeNew(ctx *koushin.Context) error { func handleComposeNew(ctx *koushin.Context) error {
// These are common mailto URL query parameters // These are common mailto URL query parameters
// TODO: cc, bcc
return handleCompose(ctx, &OutgoingMessage{ return handleCompose(ctx, &OutgoingMessage{
To: strings.Split(ctx.QueryParam("to"), ","), To: strings.Split(ctx.QueryParam("to"), ","),
Subject: ctx.QueryParam("subject"), Subject: ctx.QueryParam("subject"),

View file

@ -70,14 +70,6 @@ var allowedStyles = map[string]bool{
"list-style-position": true, "list-style-position": true,
} }
var mailtoParams = []string{
"subject",
"cc",
"bcc",
"body",
"in-reply-to",
}
type sanitizer struct { type sanitizer struct {
msg *koushinbase.IMAPMessage msg *koushinbase.IMAPMessage
} }
@ -88,31 +80,17 @@ func (san *sanitizer) sanitizeImageURL(src string) string {
return "about:blank" return "about:blank"
} }
switch strings.ToLower(u.Scheme) { // TODO: mid support?
case "mailto": if !strings.EqualFold(u.Scheme, "cid") || san.msg == nil {
mailtoQuery := u.Query()
composeURL := url.URL{Path: "/compose"}
composeQuery := make(url.Values)
composeQuery.Set("to", u.Opaque)
for _, k := range mailtoParams {
if v := mailtoQuery.Get(k); v != "" {
composeQuery.Set(k, v)
}
}
composeURL.RawQuery = composeQuery.Encode()
return composeURL.String()
case "cid":
// TODO: mid support?
part := san.msg.PartByID(u.Opaque)
if part == nil || !strings.HasPrefix(part.MIMEType, "image/") {
return "about:blank"
}
return part.URL(true).String()
default:
return "about:blank" return "about:blank"
} }
part := san.msg.PartByID(u.Opaque)
if part == nil || !strings.HasPrefix(part.MIMEType, "image/") {
return "about:blank"
}
return part.URL(true).String()
} }
func (san *sanitizer) sanitizeCSSDecls(decls []*css.Declaration) []*css.Declaration { func (san *sanitizer) sanitizeCSSDecls(decls []*css.Declaration) []*css.Declaration {