diff options
author | Simon Ser <contact@emersion.fr> | 2020-02-25 15:37:47 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-02-25 15:37:47 +0100 |
commit | 8c4fd20e2765e112518a383229a70a27b7984da3 (patch) | |
tree | 65c47a46cd442c51bdc67c755b47feefa75adb56 | |
parent | 3cfd0b942bda7392fd9f26a64251b4b08a9d2a86 (diff) | |
download | alps-8c4fd20e2765e112518a383229a70a27b7984da3.tar.gz alps-8c4fd20e2765e112518a383229a70a27b7984da3.zip |
Revert "plugins/viewhtml: convert mailto links"
This reverts commit 02faf6174b3d94efd1ee3cc842b55001639a8983.
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.
-rw-r--r-- | plugins/base/routes.go | 1 | ||||
-rw-r--r-- | plugins/viewhtml/sanitize.go | 38 |
2 files changed, 8 insertions, 31 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go index 9dd110a..ad4d121 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -431,7 +431,6 @@ func handleCompose(ctx *koushin.Context, msg *OutgoingMessage, draft *messagePat func handleComposeNew(ctx *koushin.Context) error { // These are common mailto URL query parameters - // TODO: cc, bcc return handleCompose(ctx, &OutgoingMessage{ To: strings.Split(ctx.QueryParam("to"), ","), Subject: ctx.QueryParam("subject"), diff --git a/plugins/viewhtml/sanitize.go b/plugins/viewhtml/sanitize.go index f8d6a58..c7de703 100644 --- a/plugins/viewhtml/sanitize.go +++ b/plugins/viewhtml/sanitize.go @@ -70,14 +70,6 @@ var allowedStyles = map[string]bool{ "list-style-position": true, } -var mailtoParams = []string{ - "subject", - "cc", - "bcc", - "body", - "in-reply-to", -} - type sanitizer struct { msg *koushinbase.IMAPMessage } @@ -88,31 +80,17 @@ func (san *sanitizer) sanitizeImageURL(src string) string { return "about:blank" } - switch strings.ToLower(u.Scheme) { - case "mailto": - 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" - } + // TODO: mid support? + if !strings.EqualFold(u.Scheme, "cid") || san.msg == nil { + return "about:blank" + } - return part.URL(true).String() - default: + 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 { |