aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-10-25 14:29:36 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-10-25 12:42:32 +0000
commit65e8686b0e9e909b6ea5629f95a9b14e81927872 (patch)
tree72d5dfa978f09fca4df8a6265a51a9f92f747af8 /pkg
parent42a1ab121510d4ace36fddeb7396bdb7f28bd489 (diff)
dashboard: adapt to the new Googe Groups footer
It changed recently and it broke our email discussion link extraction. Closes #5431.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/email/parser.go8
-rw-r--r--pkg/email/parser_test.go29
2 files changed, 35 insertions, 2 deletions
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)
diff --git a/pkg/email/parser_test.go b/pkg/email/parser_test.go
index 239b795a3..4c042bcfc 100644
--- a/pkg/email/parser_test.go
+++ b/pkg/email/parser_test.go
@@ -461,6 +461,35 @@ For more options, visit https://groups.google.com/d/optout.`,
},
},
}},
+ {`Date: Sun, 7 May 2017 19:54:00 -0700
+Message-ID: <123>
+Subject: new footer
+From: Bob <bob@example.com>
+To: syzbot <foo+4564456@bar.com>
+Content-Type: text/plain; charset="UTF-8"
+
+some title
+
+--
+You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
+To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com.
+To view this discussion visit https://groups.google.com/d/msgid/syzkaller-bugs/671b7fb2.050a0220.2e773.0000.GAE%40google.com.`,
+ Email{
+ BugIDs: []string{"4564456"},
+ MessageID: "<123>",
+ Date: time.Date(2017, time.May, 7, 19, 54, 0, 0, parseTestZone),
+ Link: "https://groups.google.com/d/msgid/syzkaller-bugs/671b7fb2.050a0220.2e773.0000.GAE@google.com",
+ Subject: "new footer",
+ Author: "bob@example.com",
+ Cc: []string{"bob@example.com"},
+ Body: `some title
+
+--
+You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
+To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com.
+To view this discussion visit https://groups.google.com/d/msgid/syzkaller-bugs/671b7fb2.050a0220.2e773.0000.GAE%40google.com.`,
+ Patch: "",
+ }},
{`Date: Sun, 7 May 2017 19:54:00 -0700
Message-ID: <123>