Skip to content

Commit e660d6b

Browse files
committed
Chore: Allow setting of multiple message tags via plus addresses (#253)
1 parent d1d0ce4 commit e660d6b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Diff for: internal/storage/tags.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
var (
16-
addressPlusRe = regexp.MustCompile(`^(.*){1,}\+(.*)@`)
16+
addressPlusRe = regexp.MustCompile(`(?U)^(.*){1,}\+(.*)@`)
1717
)
1818

1919
// SetMessageTags will set the tags for a given database ID
@@ -246,25 +246,25 @@ func (d DBMailSummary) tagsFromPlusAddresses() string {
246246
tags := []string{}
247247
for _, c := range d.To {
248248
matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1)
249-
if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) {
250-
tags = append(tags, matches[0][2])
249+
if len(matches) == 1 {
250+
tags = append(tags, strings.Split(matches[0][2], "+")...)
251251
}
252252
}
253253
for _, c := range d.Cc {
254254
matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1)
255-
if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) {
256-
tags = append(tags, matches[0][2])
255+
if len(matches) == 1 {
256+
tags = append(tags, strings.Split(matches[0][2], "+")...)
257257
}
258258
}
259259
for _, c := range d.Bcc {
260260
matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1)
261-
if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) {
262-
tags = append(tags, matches[0][2])
261+
if len(matches) == 1 {
262+
tags = append(tags, strings.Split(matches[0][2], "+")...)
263263
}
264264
}
265265
matches := addressPlusRe.FindAllStringSubmatch(d.From.String(), 1)
266-
if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) {
267-
tags = append(tags, matches[0][2])
266+
if len(matches) == 1 {
267+
tags = append(tags, strings.Split(matches[0][2], "+")...)
268268
}
269269

270270
return strings.Join(tags, ",")

0 commit comments

Comments
 (0)