aboutsummaryrefslogtreecommitdiffstats
path: root/pullimap
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2019-11-18 03:41:08 +0100
committerGuilhem Moulin <guilhem@fripost.org>2019-11-18 04:37:21 +0100
commit54bed5e78cacc017ad95521f3a50ebcfe344895d (patch)
treef040957c8aa17da16d9623b27ef9fbc6408a290c /pullimap
parentee040747f5f8b096f6c6ea3172826fd4c3c14053 (diff)
pullimap: Fix mangling of data lines starting with a dot.
Some LMTP servers, Dovecot's in particular, trims leading dots that are not doubled (e.g. “.foo” would become “foo”). In RFC 5322 sec. 4.5.2 explicitly says that when an RFC 5322 line starts with a '.', the character needs to be doubled.
Diffstat (limited to 'pullimap')
-rwxr-xr-xpullimap11
1 files changed, 6 insertions, 5 deletions
diff --git a/pullimap b/pullimap
index fbe300e..ee2168d 100755
--- a/pullimap
+++ b/pullimap
@@ -175,17 +175,18 @@ sub sendmail($$) {
my $length = length($$rfc822);
while ((my $end = index($$rfc822, "\r\n", $offset) + 2) != 1) {
my $line = substr($$rfc822, $offset, $end-$offset);
- # RFC 5321 section 4.5.2: the character sequence "\r\n.\r\n"
- # ends the mail text and cannot be sent by the user
- $SMTP->print($line eq ".\r\n" ? "..\r\n" : $line) or die;
+ # RFC 5321 sec. 4.5.2: if the line starts with a dot, double it
+ $line = ".".$line if substr($line, 0, 1) eq ".";
+ $SMTP->print($line) or die;
$offset = $end;
}
if ($offset < $length) {
# the last line did not end with "\r\n"; add it in order to
# have the receiving SMTP server recognize the "end of data"
- # condition. See RFC 5321 section 4.1.1.4
+ # condition. See RFC 5321 sec. 4.1.1.4
my $line = substr($$rfc822, $offset);
- $SMTP->print(($line eq "." ? ".." : $line), "\r\n") or die;
+ $line = ".".$line if substr($line, 0, 1) eq ".";
+ $SMTP->print($line, "\r\n") or die;
}
$SMTP->printflush(".\r\n") or die;
}