Skip to content

Commit

Permalink
fix(GODT-2201): Also consume new line with DONE command
Browse files Browse the repository at this point in the history
Previously we were exiting without consuming the CRLF characters causing
the next commands to fail to parse.
  • Loading branch information
LBeernaertProton authored and jameshoulahan committed Feb 16, 2023
1 parent 5640ba1 commit a99fed6
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions imap/command/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,24 @@ func (p *Parser) Parse() (Command, error) {
// Done command does not have a tag.
if strings.ToLower(tag.Value) == "done" {
p.lastCmd = "done"
result.Tag = ""
result.Payload = &Done{}
} else {
result.Tag = tag.Value
p.lastTag = tag.Value

if err := p.parser.Consume(rfcparser.TokenTypeSP, "Expected space after tag"); err != nil {
return result, err
}

return Command{
Tag: "",
Payload: &Done{},
}, nil
}

result.Tag = tag.Value
p.lastTag = tag.Value

if err := p.parser.Consume(rfcparser.TokenTypeSP, "Expected space after tag"); err != nil {
return result, err
}
payload, err := p.parseCommand()
if err != nil {
return result, err
}

payload, err := p.parseCommand()
if err != nil {
return result, err
result.Payload = payload
}

result.Payload = payload

if err := p.parser.Consume(rfcparser.TokenTypeCR, "expected CR"); err != nil {
return Command{}, err
}
Expand Down

0 comments on commit a99fed6

Please sign in to comment.