[Mimedefang] Inoffizial MIME-tools-5.411a (RP-Patched-06) available

Martin Blapp mb at imp.ch
Tue Sep 7 07:31:54 EDT 2004


Hi all,

I just made a new 'beta' release. Hopefully MIME-tools-5.412 will be soon
available:

http://people.freebsd.org/~mbr/distfiles/MIME-tools-5.411a-RP-Patched-06.tar.gz

MD5 (MIME-tools-5.411a-RP-Patched-06.tar.gz) = 93b83439d07095b3ae2657070cfc3947

This time it only contains a minor fix. Decode_qp() still corrupted some
PDFs last time. PDFs generated on UNIX and sent QP-Encoded were now currupted.

The hopefully correct patch is now below and is also present in the distfile. It
does now only correct wrong encoded PDFs generated by Outlook Express and leaves
all other PDFs alone.

Martin

--- lib/MIME/Decoder/QuotedPrint.pm.orig        Tue Aug 31 17:02:43 2004
+++ lib/MIME/Decoder/QuotedPrint.pm     Tue Aug 31 17:02:38 2004
@@ -85,9 +85,37 @@
 #
 sub decode_it {
     my ($self, $in, $out) = @_;
+    my $init = 0;
+    my $badpdf = 0;

     while (defined($_ = $in->getline)) {
-       $out->print(decode_qp($_));
+       #
+       # Dirty hack to fix QP-Encoded PDFs from MS-Outlook.
+       #
+       # Check if we have a PDF file and if it has been encoded
+       # on Windows. Unix encoded files are fine. If we have
+       # one encoded CR after the PDF init string but are missing
+       # an encoded CR before the newline this means the PDF is broken.
+       #
+       if (!$init) {
+               $init = 1;
+               if ($_ =~ /^%PDF-[0-9\.]+=0D/ && $_ !~ /(?!=0D)\n$/) {
+                       $badpdf = 1;
+               }
+       }
+       #
+       # Decode everything with decode_qp() except corrupted PDFs.
+       #
+       if ($badpdf) {
+               my $output = $_;
+               $output =~ s/[ \t]+?(\r?\n)/$1/g;
+               $output =~ s/=\r?\n//g;
+               $output =~ s/(^$|[^\r])\n\Z/$1\r\n/;
+               $output =~ s/=([\da-fA-F]{2})/pack("C", hex($1))/ge;
+               $out->print($output);
+       } else {
+               $out->print(decode_qp($_));
+       }
     }
     1;
 }




More information about the MIMEDefang mailing list