Permalink
Browse files

[fix] libnet: Fixed dot stuffing for smtpServer.

  • Loading branch information...
1 parent 32e2e4d commit faf1ba96890e9512eb5a0d8738409d1109c90da7 @nrs135 nrs135 committed with Aqua-Ye Jan 27, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 libnet/smtpServerCore.proto
View
11 libnet/smtpServerCore.proto
@@ -57,6 +57,16 @@ let rec msglst = function
| ((c,s)::rest) -> (ENs (c,s))::(msglst rest)
}}
+[[
+let unstuff(last_was_crlf, str) =
+ let str =
+ if last_was_crlf && String.length(str) >= 2 && str.[0] = '.' && str.[1] = '.'
+ then String.sub str 1 (String.length(str) - 1)
+ else str
+ in
+ String.replace str "\r\n.." "\r\n.";;
+]]
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Messages envoyés/reçus %%
%% Different structure between server and client %%
@@ -141,6 +151,7 @@ get_data(state : state, email : email, last_was_crlf : bool):
%% process_email(state, email)
receive
| RawInput str ->
+ let str = {{ unstuff(last_was_crlf,str) }}
debug {{ eprintf "get_data: RawInput='%s'\n" (String.escaped str); Pervasives.flush stderr }}
let email = {{ { email with body = content_add str email.body } }}
get_data(state, email, {{ String.is_suffix "\r\n" str }})

0 comments on commit faf1ba9

Please sign in to comment.