]> git.deb.at Git - pkg/t-prot.git/blobdiff - t-prot
Imported Upstream version 2.1
[pkg/t-prot.git] / t-prot
diff --git a/t-prot b/t-prot
index 1cd6e9d74c5c08e8c1d01a5a40c9a093a4c6e18a..81fbd71b49e6181f6771bb15b70707f7623741f0 100755 (executable)
--- a/t-prot
+++ b/t-prot
@@ -1,13 +1,13 @@
 #!/usr/bin/perl -w
-# $Id: t-prot,v 1.243 2005/05/27 10:00:35 jochen Exp $
+# $Id: t-prot,v 1.246 2006/06/17 22:45:55 jochen Exp $
 
 require 5.006;
 use strict;
 use Fcntl qw(O_EXCL O_WRONLY O_CREAT);
 use Getopt::Mixed qw(nextOption);
-use constant VER            => '2.0';
+use constant VER            => '2.1';
 use constant REV            => '';
-use constant REL            => q$Revision: 1.243 $=~m/(\d+(?:\.\d+)+)/;
+use constant REL            => q$Revision: 1.246 $=~m/(\d+(?:\.\d+)+)/;
 # MTA expecting mail on STDIN
 # (you might have to adjust this if using a different MTA)
 use constant SENDMAIL       => '/usr/sbin/sendmail -oi';
@@ -615,7 +615,7 @@ sub process_msg {
                         /^(?:\e[^\a]+\a)?\Q$mutt_attachment\E\d+/o &&
                     $att[$x+1] =~ m!^
                         (?:\e[^\a]+\a)?
-                        (?:\Q$mutt_contenttype\E) message/rfc822
+                        (?:\Q$mutt_contenttype\E) (?:message/rfc822|multipart/alternative)
                     !ox)
                 {
                     $x += 2;
@@ -634,36 +634,44 @@ sub process_msg {
     # Remove signature:
     if (scalar(@$lines)) { 
         my $sn = 0;
+        my $chk_empty = 1;
+        my $empty = 0;
+
         for ($x = $#$lines; $x>=0; $x--) {
-            if ((!$vrb[$x]) && $$lines[$x] =~ /^-- $/) {
-                if ($diff) {
-                    for (my $i=1; $x+$i+1<scalar(@$lines); $i++) {
-                        if ($$lines[$x+$i] =~ /^-{3}\s+\S/ &&
-                            $$lines[$x+$i+1] =~ /^\+{3}\s+\S/)
-                        {
-                            $sig = 0;
-                            unshift(@sig, @$lines[$x..$#$lines]);
-                            splice(@$lines, $x);
-                            last;
+            if (!$vrb[$x]) {
+                if ($$lines[$x] =~ /^-- $/) {
+                    if ($diff) {
+                        for (my $i=1; $x+$i+1<scalar(@$lines); $i++) {
+                            if ($$lines[$x+$i] =~ /^-{3}\s+\S/ &&
+                                $$lines[$x+$i+1] =~ /^\+{3}\s+\S/)
+                            {
+                                $sig = 0;
+                                unshift(@sig, @$lines[$x..$#$lines]);
+                                splice(@$lines, $x);
+                                last;
+                            }
+                        }
+                        if (scalar(@sig)) {
+                            if (defined($sign) && ++$sn==$sign) { last; } else { next; }
                         }
                     }
-                    if (scalar(@sig)) {
-                        if (defined($sign) && ++$sn==$sign) { last; } else { next; }
-                    }
-                }
 
-                if ($sig || ($lsig && ($#$lines-$x>$lsig))) {
-                    if ($lsig && !$sig) {
-                        unshift(@sig, "[---=| Overlong signature removed by $0: " .
-                            (scalar(@$lines)-$x) . " lines snipped |=---]\n");
+                    if ($sig || ($lsig && ($#$lines-$x-$empty>$lsig))) {
+                        if ($lsig && !$sig) {
+                            unshift(@sig, "[---=| Overlong signature removed by $0: " .
+                                (scalar(@$lines)-$x) . " lines snipped |=---]\n");
+                        }
+                        splice(@$lines, $x);
                     }
-                    splice(@$lines, $x);
-                }
-                else {
-                    unshift(@sig, @$lines[$x..$#$lines]);
-                    splice(@$lines, $x);
+                    else {
+                        unshift(@sig, @$lines[$x..$#$lines]);
+                        splice(@$lines, $x);
+                    }
+                    if (defined($sign) && ++$sn==$sign) { last; } else { next; }
                 }
-                if (defined($sign) && ++$sn==$sign) { last; } else { next; }
+                # any trailing newlines?
+                elsif ($chk_empty && $$lines[$x] =~ /^\s*$/) { $empty++; }
+                elsif ($chk_empty) { $chk_empty = 0; }
             }
         }
     }