mirror of
https://github.com/reactos/syzkaller.git
synced 2025-02-10 13:54:15 +00:00
pkg/email: fix bug in context extraction
Compare email addresses without full name.
This commit is contained in:
parent
6fe1bcf384
commit
f68d78b5a8
@ -49,8 +49,14 @@ func Parse(r io.Reader, ownEmail string) (*Email, error) {
|
||||
cc, _ := msg.Header.AddressList("Cc")
|
||||
bugID := ""
|
||||
var ccList []string
|
||||
if addr, err := mail.ParseAddress(ownEmail); err == nil {
|
||||
ownEmail = addr.Address
|
||||
}
|
||||
for _, addr := range append(cc, to...) {
|
||||
cleaned, context, _ := RemoveAddrContext(addr.Address)
|
||||
if addr, err := mail.ParseAddress(cleaned); err == nil {
|
||||
cleaned = addr.Address
|
||||
}
|
||||
if cleaned == ownEmail {
|
||||
if bugID == "" {
|
||||
bugID = context
|
||||
|
@ -78,7 +78,7 @@ func TestAddRemoveAddrContext(t *testing.T) {
|
||||
func TestParse(t *testing.T) {
|
||||
for i, test := range parseTests {
|
||||
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
||||
email, err := Parse(strings.NewReader(test.email), "")
|
||||
email, err := Parse(strings.NewReader(test.email), "bot <foo@bar.com>")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -133,7 +133,7 @@ var parseTests = []struct {
|
||||
Message-ID: <123>
|
||||
Subject: test subject
|
||||
From: Bob <bob@example.com>
|
||||
To: syzbot <bot@example.com>
|
||||
To: syzbot <foo+4564456@bar.com>
|
||||
Content-Type: text/plain; charset="UTF-8"
|
||||
|
||||
text body
|
||||
@ -141,10 +141,10 @@ second line
|
||||
#syzbot command arg1 arg2 arg3
|
||||
last line`,
|
||||
&Email{
|
||||
BugID: "4564456",
|
||||
MessageID: "<123>",
|
||||
Subject: "test subject",
|
||||
From: "\"Bob\" <bob@example.com>",
|
||||
Cc: []string{"\"syzbot\" <bot@example.com>"},
|
||||
Body: `text body
|
||||
second line
|
||||
#syzbot command arg1 arg2 arg3
|
||||
|
Loading…
x
Reference in New Issue
Block a user