summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-05-27 19:25:28 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-05-27 19:26:38 +0200
commit778853929562100fc111afa8a244111c24747e89 (patch)
tree13b3fd14a1b4db9e1896c011b62a6923c6ae097d
parent76042851b82d9471991440856182da4bff03be7f (diff)
downloadmum-778853929562100fc111afa8a244111c24747e89.tar.gz
m-pop: Fix From: header parsingHEADmaster
Now, it handles From: headers split across multiple lines.
-rwxr-xr-xsrc/m-pop13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/m-pop b/src/m-pop
index e7cebae..7b34086 100755
--- a/src/m-pop
+++ b/src/m-pop
@@ -87,17 +87,18 @@ for my $id (@ids) {
chomp(@msg = @{$pop->get($id)});
}
- # Make From_ line
- my ($from, $from_alt);
+ # Find address in From: header and make From_ line
+ my $from;
my $j = 0; # index of empty line before message body
for (@msg) {
last if /^$/;
+ if (/^[Ff]rom: / .. not $msg[$j+1] =~ /^[ \t]/) {
+ /^(?: From:\ | [ \t]+) (.*)/x;
+ $from .= " $1" if $1;
+ }
$j++;
- $from = $1 if /^From: (.*)$/;
- $from_alt = $1 if /^from: (.*)$/;
}
- $from = $from_alt if $from_alt and not $from;
- $from = $1 if $from and $from =~ /^.* <(.*?@.*?)>$/;
+ $from = $1 if $from and $from =~ /^.* <(.*?@.*?)>$/s;
$from = 'MAILER-DAEMON@' . hostname if not $from;
my $from_ = "From $from $date";