Skip to content

Commit ef89036

Browse files
qjebbsemersion
authored andcommitted
imapwire: accept trailing space in CAPABILITY/SEARCH responses
imap.exmail.qq.com sends: * CAPABILITY IMAP4<SP>IMAP4rev1<SP><CRLF> smtp-n.global-mail.cn sends: * SEARCH<SP><CRLF>
1 parent 5695437 commit ef89036

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/imapwire/decoder.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ func (dec *Decoder) Expect(ok bool, name string) bool {
135135

136136
func (dec *Decoder) SP() bool {
137137
if dec.acceptByte(' ') {
138-
return true
138+
// https://github.com/emersion/go-imap/issues/571
139+
b, ok := dec.readByte()
140+
if !ok {
141+
return false
142+
}
143+
dec.mustUnreadByte()
144+
return b != '\r' && b != '\n'
139145
}
140146

141147
// Special case: SP is optional if the next field is a parenthesized list

0 commit comments

Comments
 (0)