From e660d6beddbfa2c626ce8e96d54468c22f94e71e Mon Sep 17 00:00:00 2001 From: Ralph Slooten <axllent@gmail.com> Date: Sun, 10 Mar 2024 08:05:11 +1300 Subject: [PATCH] Chore: Allow setting of multiple message tags via plus addresses (#253) --- internal/storage/tags.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/storage/tags.go b/internal/storage/tags.go index 3341e70..2dec4db 100644 --- a/internal/storage/tags.go +++ b/internal/storage/tags.go @@ -13,7 +13,7 @@ import ( ) var ( - addressPlusRe = regexp.MustCompile(`^(.*){1,}\+(.*)@`) + addressPlusRe = regexp.MustCompile(`(?U)^(.*){1,}\+(.*)@`) ) // SetMessageTags will set the tags for a given database ID @@ -246,25 +246,25 @@ func (d DBMailSummary) tagsFromPlusAddresses() string { tags := []string{} for _, c := range d.To { matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1) - if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) { - tags = append(tags, matches[0][2]) + if len(matches) == 1 { + tags = append(tags, strings.Split(matches[0][2], "+")...) } } for _, c := range d.Cc { matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1) - if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) { - tags = append(tags, matches[0][2]) + if len(matches) == 1 { + tags = append(tags, strings.Split(matches[0][2], "+")...) } } for _, c := range d.Bcc { matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1) - if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) { - tags = append(tags, matches[0][2]) + if len(matches) == 1 { + tags = append(tags, strings.Split(matches[0][2], "+")...) } } matches := addressPlusRe.FindAllStringSubmatch(d.From.String(), 1) - if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) { - tags = append(tags, matches[0][2]) + if len(matches) == 1 { + tags = append(tags, strings.Split(matches[0][2], "+")...) } return strings.Join(tags, ",")