aboutsummaryrefslogtreecommitdiffstats
path: root/pullimap
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2016-06-25 21:30:35 +0200
committerGuilhem Moulin <guilhem@fripost.org>2016-06-25 21:30:35 +0200
commitbf57c46e0292f64a637fcee92abcdc0e79c6c53e (patch)
treed86f3df6244e1844925ca7cec10eac1309eb0060 /pullimap
parentf16e7ab218985c72ccebda2c1e93ba41ba9a1121 (diff)
parent063af8ae790e4e67087aa1ed51aceae1a3b77be0 (diff)
Merge branch 'master' into debian
Diffstat (limited to 'pullimap')
-rwxr-xr-xpullimap13
1 files changed, 12 insertions, 1 deletions
diff --git a/pullimap b/pullimap
index e971f64..d176464 100755
--- a/pullimap
+++ b/pullimap
@@ -269,13 +269,24 @@ sub purge() {
my $ATTRS = "ENVELOPE INTERNALDATE";
$ATTRS .= " BODY.PEEK[]" unless $CONFIG{'no-delivery'};
+my $RE_ATOM = qr/[A-Za-z0-9\x21\x23-\x27\x2A\x2B\x2D\x2F\x3D\x3F\x5E-\x60\x7B-\x7E]+/;
sub pull_callback($$) {
my ($uids, $mail) = @_;
return unless exists $mail->{RFC822} or $CONFIG{'no-delivery'}; # not for us
my $uid = $mail->{UID};
my $from = first { defined $_ and @$_ } @{$mail->{ENVELOPE}}[2,3,4];
- $from = (defined $from and @$from) ? $from->[0]->[2].'@'.$from->[0]->[3] : '';
+ if (defined $from and @$from) {
+ my ($l, $d) = @{$from->[0]}[2,3];
+ unless ($l =~ /\A$RE_ATOM(?:\.$RE_ATOM)*\z/o) { # quote the local part if not Dot-string (RFC 5321)
+ $l =~ s/([\x22\x5C])/\\$1/g; # escape double-quote and backslash
+ $l = '"' .$l. '"';
+ }
+ $from = $l .'@'. $d;
+ $IMAP->fail("Invalid character in MAIL FROM: <$from>") unless $l =~ /\A[\x20-\x7E]*\z/;
+ } else {
+ $from = '';
+ }
$IMAP->log("UID $uid from <$from> ($mail->{INTERNALDATE})") unless $CONFIG{quiet};
sendmail($from, $mail->{RFC822}) unless $CONFIG{'no-delivery'};