mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 16:33:47 +03:00
webmail: recognize multiple urls in List-Post addresses
there may be a http(s)-address, which we'll ignore. the mailto may come after that. like in google groups.
This commit is contained in:
parent
8654a1f901
commit
8bcce40c55
2 changed files with 25 additions and 16 deletions
|
@ -369,17 +369,19 @@ func parseListPostAddress(s string) *MessageAddress {
|
|||
List-Post: <mailto:moderator@host.com> (Postings are Moderated)
|
||||
List-Post: <mailto:moderator@host.com?subject=list%20posting>
|
||||
List-Post: NO (posting not allowed on this list)
|
||||
List-Post: <https://groups.google.com/group/golang-dev/post>, <mailto:golang-dev@googlegroups.com>
|
||||
*/
|
||||
s = strings.TrimSpace(s)
|
||||
if !strings.HasPrefix(s, "<mailto:") {
|
||||
for s != "" {
|
||||
if !strings.HasPrefix(s, "<") {
|
||||
return nil
|
||||
}
|
||||
s = s[1:]
|
||||
s, _, found := strings.Cut(s, ">")
|
||||
addr, ns, found := strings.Cut(s[1:], ">")
|
||||
if !found {
|
||||
return nil
|
||||
}
|
||||
u, err := url.Parse(s)
|
||||
if strings.HasPrefix(addr, "mailto:") {
|
||||
u, err := url.Parse(addr)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -388,4 +390,10 @@ func parseListPostAddress(s string) *MessageAddress {
|
|||
return nil
|
||||
}
|
||||
return &MessageAddress{User: addr.Localpart.String(), Domain: addr.Domain}
|
||||
}
|
||||
s = strings.TrimSpace(ns)
|
||||
s = strings.TrimPrefix(s, ",")
|
||||
s = strings.TrimSpace(s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -45,5 +45,6 @@ func TestParseListPostAddress(t *testing.T) {
|
|||
check("<mailto:moderator@host.com> (Postings are Moderated)", &MessageAddress{User: "moderator", Domain: dns.Domain{ASCII: "host.com"}})
|
||||
check("<mailto:moderator@host.com?subject=list%20posting>", &MessageAddress{User: "moderator", Domain: dns.Domain{ASCII: "host.com"}})
|
||||
check("NO (posting not allowed on this list)", nil)
|
||||
check("<https://groups.google.com/group/golang-dev/post>, <mailto:golang-dev@googlegroups.com>", &MessageAddress{User: "golang-dev", Domain: dns.Domain{ASCII: "googlegroups.com"}})
|
||||
check("", nil)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue