Skip to content

Commit

Permalink
dashboard: adapt to the new Googe Groups footer
Browse files Browse the repository at this point in the history
It changed recently and it broke our email discussion link extraction.

Closes google#5431.
  • Loading branch information
a-nogikh committed Oct 25, 2024
1 parent 42a1ab1 commit 65e8686
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/email/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"mime/multipart"
"mime/quotedprintable"
"net/mail"
"net/url"
"regexp"
"sort"
"strings"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
29 changes: 29 additions & 0 deletions pkg/email/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
To: syzbot <[email protected]>
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 [email protected].
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/[email protected]",
Subject: "new footer",
Author: "[email protected]",
Cc: []string{"[email protected]"},
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 [email protected].
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>
Expand Down

0 comments on commit 65e8686

Please sign in to comment.