about summary refs log tree commit diff stats
path: root/commands/msg
diff options
context:
space:
mode:
Diffstat (limited to 'commands/msg')
-rw-r--r--commands/msg/reply.go25
1 files changed, 3 insertions, 22 deletions
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index e09a118..a9ae5a1 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -6,7 +6,6 @@ import (
 	"fmt"
 	"io"
 	gomail "net/mail"
-	"regexp"
 	"strings"
 
 	"git.sr.ht/~sircmpwn/getopt"
@@ -15,6 +14,7 @@ import (
 	_ "github.com/emersion/go-message/charset"
 	"github.com/emersion/go-message/mail"
 
+	"git.sr.ht/~sircmpwn/aerc/lib"
 	"git.sr.ht/~sircmpwn/aerc/widgets"
 )
 
@@ -23,25 +23,6 @@ func init() {
 	register("forward", Reply)
 }
 
-var (
-	atom *regexp.Regexp = regexp.MustCompile("^[a-z0-9!#$%7'*+-/=?^_`{}|~ ]+$")
-)
-
-func formatAddress(addr *imap.Address) string {
-	if addr.PersonalName != "" {
-		if atom.MatchString(addr.PersonalName) {
-			return fmt.Sprintf("%s <%s@%s>",
-				addr.PersonalName, addr.MailboxName, addr.HostName)
-		} else {
-			return fmt.Sprintf("\"%s\" <%s@%s>",
-				strings.ReplaceAll(addr.PersonalName, "\"", "'"),
-				addr.MailboxName, addr.HostName)
-		}
-	} else {
-		return fmt.Sprintf("<%s@%s>", addr.MailboxName, addr.HostName)
-	}
-}
-
 func Reply(aerc *widgets.Aerc, args []string) error {
 	opts, optind, err := getopt.Getopts(args[1:], "aq")
 	if err != nil {
@@ -96,14 +77,14 @@ func Reply(aerc *widgets.Aerc, args []string) error {
 		}
 		if replyAll {
 			for _, addr := range msg.Envelope.Cc {
-				cc = append(cc, formatAddress(addr))
+				cc = append(cc, lib.FormatAddress(addr))
 			}
 			for _, addr := range msg.Envelope.To {
 				address := fmt.Sprintf("%s@%s", addr.MailboxName, addr.HostName)
 				if address == us.Address {
 					continue
 				}
-				to = append(to, formatAddress(addr))
+				to = append(to, lib.FormatAddress(addr))
 			}
 		}
 	}
committer Ben Morrison <ben@gbmor.dev> 2019-05-27 01:06:50 -0400 changed config format to yaml, commented config file' href='/gbmor/getwtxt/commit/getwtxt.yml?h=v0.4.7&id=daa48539f5ad8b444637f948b98996d35852b1e8'>daa4853 ^
579c0be ^




daa4853 ^



69217dd ^
daa4853 ^
1e0e919 ^




daa4853 ^
















1e0e919 ^



daa4853 ^

c5cf0e1 ^

daa4853 ^

c5cf0e1 ^
daa4853 ^



c5cf0e1 ^
daa4853 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106