From 65e8686b0e9e909b6ea5629f95a9b14e81927872 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 25 Oct 2024 14:29:36 +0200 Subject: dashboard: adapt to the new Googe Groups footer It changed recently and it broke our email discussion link extraction. Closes #5431. --- pkg/email/parser.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pkg/email/parser.go') diff --git a/pkg/email/parser.go b/pkg/email/parser.go index e8aa1a8c0..b748d02c3 100644 --- a/pkg/email/parser.go +++ b/pkg/email/parser.go @@ -11,6 +11,7 @@ import ( "mime/multipart" "mime/quotedprintable" "net/mail" + "net/url" "regexp" "sort" "strings" @@ -59,8 +60,8 @@ const ( cmdTest5 ) -var groupsLinkRe = regexp.MustCompile("\nTo view this discussion on the web visit" + - " (https://groups\\.google\\.com/.*?)\\.(?:\r)?\n") +var groupsLinkRe = regexp.MustCompile(`(?m)\nTo view this discussion (?:on the web )?visit` + + ` (https://groups\.google\.com/.*?)\.(:?$|\n|\r)`) func prepareEmails(list []string) map[string]bool { ret := make(map[string]bool) @@ -153,6 +154,9 @@ func Parse(r io.Reader, ownEmails, goodLists, domains []string) (*Email, error) link := "" if match := groupsLinkRe.FindStringSubmatchIndex(bodyStr); match != nil { link = bodyStr[match[2]:match[3]] + if unescaped, err := url.QueryUnescape(link); err == nil { + link = unescaped + } } author := CanonicalEmail(from[0].Address) -- cgit mrf-deployment