Discard periods prefixing SMTP data per RFC 821 4.5.2

This commit is contained in:
Samuel Cochran 2012-07-18 11:27:27 +08:00
parent cfdadc01fd
commit 20cf6e98f1
2 changed files with 18 additions and 1 deletions

14
examples/dotmail Normal file
View File

@ -0,0 +1,14 @@
To: Blah <blah@blah.com>
From: Me <me@sj26.com>
Subject: Whatever
Content-Type: text/plain
Plain text mail
With some dot lines:
.
...
Done.

View File

@ -34,7 +34,10 @@ class MailCatcher::Smtp < EventMachine::Protocols::SmtpServer
def receive_data_chunk(lines)
current_message[:source] ||= ""
current_message[:source] += lines.join("\n")
lines.each do |line|
# RFC821 4.5.2 says leading periods should be stripped from the body data.
current_message[:source] << line.sub(/\A\./, "") << "\n"
end
true
end