Skip to content

Commit e5cfa0c

Browse files
author
Sven Liebert
committed
Prevent problem when quotation marks are in subject or mail body
1 parent 689cb7a commit e5cfa0c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

service/cmd/server/main.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func jsonEscape(i string) string {
4545
log.Println(err)
4646
}
4747
s := string(b)
48-
return s[1:len(s)-1]
48+
return s[1 : len(s)-1]
4949
}
5050

5151
func getAddIssueResponse(resp *http.Response) AddIssueResponse {
@@ -158,6 +158,12 @@ func makeGetRequest(endpoint string) *http.Response {
158158
return resp
159159
}
160160

161+
func replaceQuotationMarks(value string) string {
162+
value = strings.Replace(value, "\"", "'", -1)
163+
164+
return value
165+
}
166+
161167
func setMailAsSeenForService(c *client.Client, currentMail uint32) {
162168
seqSet := new(imap.SeqSet)
163169
seqSet.AddRange(currentMail, currentMail)
@@ -232,7 +238,7 @@ func run() {
232238
currentUid := uids[currentMessage]
233239

234240
r := message.GetBody(&section)
235-
subject := message.Envelope.Subject
241+
subject := replaceQuotationMarks(message.Envelope.Subject)
236242

237243
isMessageWithIssueNumber, _ := regexp.MatchString("^.*\\[.*-\\d+]$", subject)
238244

@@ -264,7 +270,7 @@ func run() {
264270

265271
switch h := p.Header.(type) {
266272
case *mail.InlineHeader:
267-
sanitizedBody := getMailBody(p)
273+
sanitizedBody := replaceQuotationMarks(getMailBody(p))
268274
contentType, _, _ := h.ContentType()
269275

270276
if contentType != "text/plain" {

0 commit comments

Comments
 (0)