Skip to content

Commit bd1efd5

Browse files
DenBekersc
authored andcommitted
net/mail: fixed quoted-local
Fixes some minor issues regarding quoted-string when parsing the local-part. Those strings should return an error: - quoted-string without any content: `""@test.com` - quoted-string containing tab: "\"\t\"@test.com" Fixes #11293 Change-Id: Ied93eb6831915c9b1f8e727cea14168af21f8d3b Reviewed-on: https://go-review.googlesource.com/12905 Reviewed-by: Russ Cox <rsc@golang.org>
1 parent 782eea0 commit bd1efd5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/net/mail/message.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ Loop:
419419
}
420420
qsb = append(qsb, p.s[i+1])
421421
i += 2
422-
case isQtext(c), c == ' ' || c == '\t':
422+
case isQtext(c), c == ' ':
423423
// qtext (printable US-ASCII excluding " and \), or
424424
// FWS (almost; we're ignoring CRLF)
425425
qsb = append(qsb, c)
@@ -429,6 +429,9 @@ Loop:
429429
}
430430
}
431431
p.s = p.s[i+1:]
432+
if len(qsb) == 0 {
433+
return "", errors.New("mail: empty quoted-string")
434+
}
432435
return string(qsb), nil
433436
}
434437

src/net/mail/message_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ func TestAddressParsingAndFormatting(t *testing.T) {
522522
`<".john.doe"@example.com>`,
523523
`<"."@example.com>`,
524524
`<".."@example.com>`,
525+
`<"0:"@0>`,
525526
}
526527

527528
for _, test := range tests {
@@ -563,6 +564,8 @@ func TestAddressParsingAndFormatting(t *testing.T) {
563564
`<test@.>`,
564565
`< @example.com>`,
565566
`<""test""blah""@example.com>`,
567+
`<""@0>`,
568+
"<\"\t0\"@0>",
566569
}
567570

568571
for _, test := range badTests {

0 commit comments

Comments
 (0)