aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/email/parser.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-07-03 18:24:39 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-07-03 18:24:39 +0200
commitebabe267cda9c25d5789f647339d237893eed10e (patch)
treedc605ff16357695eefba776710cfbbb0ce55dca2 /pkg/email/parser.go
parent2181ef35e17d97286cfe7edad5d4d68c225922d9 (diff)
pkg/email: don't add own email address to CC list
Otherwise we we send each reply to ourselves and receive it again.
Diffstat (limited to 'pkg/email/parser.go')
-rw-r--r--pkg/email/parser.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/pkg/email/parser.go b/pkg/email/parser.go
index a764a5826..5d8c54d2c 100644
--- a/pkg/email/parser.go
+++ b/pkg/email/parser.go
@@ -50,10 +50,13 @@ func Parse(r io.Reader, ownEmail string) (*Email, error) {
bugID := ""
var ccList []string
for _, addr := range append(cc, to...) {
+ bugID1, own := extractBugID(addr.Address, ownEmail)
if bugID == "" {
- bugID = extractBugID(addr.Address, ownEmail)
+ bugID = bugID1
+ }
+ if !own {
+ ccList = append(ccList, addr.String())
}
- ccList = append(ccList, addr.String())
}
body, attachments, err := parseBody(msg.Body, msg.Header)
if err != nil {
@@ -89,25 +92,26 @@ func Parse(r io.Reader, ownEmail string) (*Email, error) {
// from is potentially such email address, canonical is <something@something.com>.
// This function returns BUG_ID_HASH, or an empty string if from does not contain
// the hash or is different from canonical.
-func extractBugID(from, canonical string) string {
+func extractBugID(from, canonical string) (string, bool) {
if email, err := mail.ParseAddress(canonical); err == nil {
canonical = email.Address
}
+ canonical = strings.ToLower(canonical)
plusPos := strings.IndexByte(from, '+')
if plusPos == -1 {
- return ""
+ return "", strings.ToLower(from) == canonical
}
atPos := strings.IndexByte(from[plusPos:], '@')
if atPos == -1 {
- return ""
+ return "", false
}
user := from[:plusPos]
domain := from[plusPos+atPos:]
hash := from[plusPos+1 : plusPos+atPos]
- if strings.ToLower(user+domain) != strings.ToLower(canonical) {
- return ""
+ if strings.ToLower(user+domain) != canonical {
+ return "", false
}
- return hash
+ return hash, true
}
// extractCommand extracts command to syzbot from email body.