From e975445862a1700cf05c574db979346d6ca4a4fd Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Sat, 7 Feb 2015 13:32:24 +0100 Subject: [PATCH] Fixed non-RFC-compliant handling of lines starting with dots MgSMTP is now compliant with the transparency guidelines suggested in RFC 5321, section 4.5.2. modified: Listener.pas modified: MgSMTP.pas modified: Relay.pas modified: todo.txt --- Listener.pas | 7 +++++-- MgSMTP.pas | 2 +- Relay.pas | 7 +++++++ todo.txt | 3 +++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Listener.pas b/Listener.pas index a4d94f0..b37662b 100644 --- a/Listener.pas +++ b/Listener.pas @@ -507,8 +507,11 @@ begin Done:= false; repeat ReadOK:= TCP.ReadLn(Line); - if Line <> '.' then - SpoolObject.DeliverMessagePart(Line) + if Line <> '.' then begin + { If the line starts with a dot, remove it to comply with RFC. } + if (Length(Line) > 1) and (Line[1] = '.') then Delete(Line, 1, 1); + SpoolObject.DeliverMessagePart(Line); + end else Done:= true; until Done or (not ReadOK); diff --git a/MgSMTP.pas b/MgSMTP.pas index 808a90d..3e6ddfb 100644 --- a/MgSMTP.pas +++ b/MgSMTP.pas @@ -49,7 +49,7 @@ const document what bugfix/feature are you testing with the actual build. This will be logged to help you differentiate outputs of subsequent builds in your logs. If left empty, it won't be added to the logs. } - DEVCOMMENT = 'New feature to add "Reply-To" to forwarded messages'; + DEVCOMMENT = 'Escaping dots'; var diff --git a/Relay.pas b/Relay.pas index 4984bc1..1e42979 100644 --- a/Relay.pas +++ b/Relay.pas @@ -474,7 +474,14 @@ end; function TRelayer.DeliverMessagePart(Chunk: TStrings): boolean; { Sends a chunk of the message. } +var i: integer; begin + { Check for lines starting with dots. } + for i:= 0 to Chunk.Count - 1 do + if (Length(Chunk.Strings[i]) > 0) and (Chunk.Strings[i][1] = '.') then + Chunk.Strings[i]:= '.' + Chunk.Strings[i]; + + { Send text. } Result:= TCP.WriteBuffer(PChar(Chunk.Text), Length(Chunk.Text)) <> -1; end; diff --git a/todo.txt b/todo.txt index 7a59bc3..3c871a0 100644 --- a/todo.txt +++ b/todo.txt @@ -26,6 +26,9 @@ v0.9t: - IPv6 - Bind to user-specified IPs + Option to add Reply-To header to forwarded e-mails ++ Fix non-RFC-compliant handling of lines starting with dots +- Fall back to HELO when remote server doesn't support EHLO +- Implement CHUNKING extension v0.9s: + Change "Client disconnected, and thread exited successfully." to "Client disconnected." -- 2.34.1