axllent / mailpit

An email and SMTP testing tool with API for developers

Home Page:https://mailpit.axllent.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

POP3 server does not do dot stuffing

henningp opened this issue · comments

The POP3 server currently doesn't do "dot stuffing".

From the POP3 spec:

When all lines of the response have been sent, a
final line is sent, consisting of a termination octet (decimal code
046, ".") and a CRLF pair. If any line of the multi-line response
begins with the termination octet, the line is "byte-stuffed" by
pre-pending the termination octet to that line of the response.

In practice, this means that any message line starting with a dot must have an extra dot added at the start of the line. (The same technique is used in SMTP.) Mailpit's POP3 doesn't do this, resulting in dots at the start of lines going missing when getting messages via POP3.

@henningp - thank you, I did not know this. So if I understand this correctly, a message that contains the following in the returned body (from a POP3 server):

this is a test
.02 test
blaah

would get "translated" (transformed) by any POP3 client to:

this is a test
02 test
blaah

?

In order to address this, we need to prepend a dot on any line that starts with a dot to result in:

this is a test
..02 test
blaah

Am I 100% correct in my understanding?

Hi @axllent, neither did I know about this until this week, and it was a royal pain to debug 😀 Yes, your understanding is exactly correct! Thanks for your swift reply.
I‘m running a patched Mailpit for now with this fix, and that stopped dots from going missing seemingly at random in my tests using POP3.

Thanks so much @henningp - I really appreciate it! I suspect I may have come across this issue before but never worked it out :-)

Your patch looks good (well done) - so I'll merge this soon (I'm just working on something else right now) and get a new release out as soon as I can.

Brilliant, thanks! 😊

This has been released in v1.18.3 :) Thanks again for your PR @henningp!

Oh wow, thank you @axllent! :-D