+FIXME comments
authorshort <>
Sun, 6 Oct 2002 19:42:09 +0000 (19:42 +0000)
committershort <>
Sun, 6 Oct 2002 19:42:09 +0000 (19:42 +0000)
+razor2 SIGPIPE graceful handling
&muttrc_get: Improved string decoding
&store_muttrc_alternates: self-email now required as "set from" in Muttrc
 - previously used "my_hdr From: ..."

perlmail-accept

index 0e68b3d..09bdc03 100755 (executable)
@@ -96,6 +96,7 @@ sub stdin
        exit 0;
 }
 
+# FIXME: separate 'lacemail'-transfer together with lacemail-submit away
 sub inetd
 {
        die "Excessive arguments" if @ARGV;
@@ -242,6 +243,7 @@ my($smsi,$smscount)=@_;
        return "";
 }
 
+# FIXME: rewrite &send_cz_eurotel properly by own code
 # patch for http://kiwi.ms.mff.cuni.cz/%7Etom/programming/src/sendsms.tar.gz/sendsms.pl
 my $agent=LWP::UserAgent->new();
 $agent->agent("LaceMail $VERSION; contact=$SMScontact; ");
@@ -577,6 +579,7 @@ sub razor2
 {
        # razor-check has exit code 1 if NOT spam, code 0 if IS spam
        local *CHILD;
+       local $SIG{"PIPE"}=sub { warn "razor2 gave me SIGPIPE: broken pipe"; };
        # prevent Razor2's: Can't call method "log" on unblessed reference at Razor2/Client/Agent.pm line 212.
        local $ENV{"HOME"}=$HOME;
        open CHILD,'|'
@@ -644,16 +647,34 @@ my($muttrc)=@_;
        return wantarray() ? @r : join("",map("$_\n",@r));
 }
 
+my %mutteval_charmap=(         # WARNING: Don't use "" or "0" here, see below for "|| warn"!
+               '\\'=>"\\",
+               'r'=>"\r",
+               'n'=>"\n",
+               't'=>"\t",
+               'f'=>"\f",
+               'e'=>"\e",
+               );
+# mutt/init.c/mutt_extract_token()
+sub mutteval
+{
+       local $_=$_[0];
+       return $_ if !s/^"//;
+       do { warn "Missing trailing quote in: $_"; return $_; } if !s/"$//;
+       s/\\(.)/$mutteval_charmap{$1} || warn "Undefined '\\$1' sequence in: $_";/ges;
+       return $_;
+}
+
 sub muttrc_get
 {
 my(@headers)=@_;
 
-       my @r=map({ (ref $_ ? $_ : qr/^\s*set\s+\Q$_\E\s*=\s*"([^"]*)"\s*$/si); } @headers);
+       my @r=map({ (ref $_ ? $_ : qr/^\s*set\s+\Q$_\E\s*=\s*(.*?)\s*$/si); } @headers);
        my %r=map(($_=>undef()),@r);
        for (muttrc()) {
                for my $ritem (@r) {
                        /$ritem/si or next;
-                       $r{$ritem}=$1;
+                       $r{$ritem}=mutteval $1;
                        }
                }
        for my $var (grep { !defined($r{$_}) } @r) {
@@ -677,13 +698,15 @@ sub muttrc_aliases
        return %r;
 }
 
+# FIXME: host may get multiple recipients and thus not showing "for <...>"
+# FIXME: muttrc_get("from") is too strict
 sub store_muttrc_alternates
 {
 my($prefix,$profile)=@_;
 
        my $alternates=muttrc_get("alternates") or return;
        my $alternatesre=qr/$alternates/si;
-       my $From=muttrc_get(qr/^\s*my_hdr\s+From:.*\<(\S+)\>\s*$/si) or return;
+       my $From=muttrc_get("from") or return;
        my $Fromre=qr/^\Q$From\E$/si;
        warn "'From' \"$From\" not matches by 'alternates': $alternatesre"
                        if $From!~/$alternates/si;