diff --git a/webmail/message.go b/webmail/message.go index 5c1376f..1128371 100644 --- a/webmail/message.go +++ b/webmail/message.go @@ -316,12 +316,12 @@ func parseListPostAddress(s string) *MessageAddress { if !strings.HasPrefix(s, "", 2) - if len(t) != 2 { + s = s[1:] + s, _, found := strings.Cut(s, ">") + if !found { return nil } - u, err := url.Parse(t[0]) + u, err := url.Parse(s) if err != nil { return nil } diff --git a/webmail/message_test.go b/webmail/message_test.go new file mode 100644 index 0000000..3d107ab --- /dev/null +++ b/webmail/message_test.go @@ -0,0 +1,21 @@ +package webmail + +import ( + "testing" + + "github.com/mjl-/mox/dns" +) + +func TestParseListPostAddress(t *testing.T) { + check := func(s string, exp *MessageAddress) { + t.Helper() + v := parseListPostAddress(s) + tcompare(t, v, exp) + } + + check("", &MessageAddress{User: "list", Domain: dns.Domain{ASCII: "host.com"}}) + check(" (Postings are Moderated)", &MessageAddress{User: "moderator", Domain: dns.Domain{ASCII: "host.com"}}) + check("", &MessageAddress{User: "moderator", Domain: dns.Domain{ASCII: "host.com"}}) + check("NO (posting not allowed on this list)", nil) + check("", nil) +}