alienscience / imapsrv

An IMAP server written in Go
BSD 3-Clause "New" or "Revised" License
48 stars 9 forks source link

Handle missing tag error #6

Closed g-dormoy closed 9 years ago

g-dormoy commented 9 years ago

From the RFC 3501 :

The client command begins an operation. Each client command is prefixed with an identifier (typically a short alphanumeric string, e.g., A0001, A0002, etc.) called a "tag". A different tag is generated by the client for each command.

Clients MUST follow the syntax outlined in this specification strictly. It is a syntax error to send a command with missing or extraneous spaces or arguments.

If the tag is replaced by a space shouldn't we return an error to the client?

example BAD Protocol Error: "Tag not found in command".

For now the space seems to be omited

twitchyliquid64 commented 9 years ago

Hmmmm. Correct.

Would you like to fix?

g-dormoy commented 9 years ago

Sure I wanted to make sure we agreed on that

alienscience commented 9 years ago

I think that the error is in lexer.astring(). Section 9 of the RFC describes the real grammar.

g-dormoy commented 9 years ago

The problem is also the lexer.skipSpace() at the beginning of lexer.next().

g-dormoy commented 9 years ago

I've commited a fix for that one, i've added a slice of bytes to handle the exception on astring accordingly to the section 9 of the RFC as alien pointed out.

I've made my test on my side but feel free to tell me if I've missed something