[Mimedefang] Inoffizial MIME-tools-5.411a-RP-Patched-05 available (includes a new data corruption fix)

Martin Blapp mb at imp.ch
Wed Sep 1 03:59:57 EDT 2004


Hi,

> "Fixing" PDF files will "break" other files.  It is simply inappropriate to
> transmit PDF files using Quoted-Printable encoding, and any software that
> does so deserves to have its PDF attachments broken.

That's not true. Look at the workaround itself:

Only real PDF files get converted, the first line must match the
'%PDF' pattern.

For all other files we use decode_qp() patch.

I really hope that you don't reject this patch ! It doesn't break anything.

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,26 @@
 #
 sub decode_it {
     my ($self, $in, $out) = @_;
+    my $init = 0;
+    my $havepdf = 0;

     while (defined($_ = $in->getline)) {
-       $out->print(decode_qp($_));
+       if (!$init) {
+               if ($_ =~ /^%PDF/) {
+                       $init = 1;
+                       $havepdf = 1;
+               }
+       }
+       if ($havepdf) {
+               my $output = $_;
+               $output =~ s/[ \t]+?(\r?\n)/$1/g;  # rule #3 (trailing space must be deleted)
+               $output =~ s/=\r?\n//g;            # rule #5 (soft line breaks)
+               $output =~ s/(^|[^\r])\n\Z/$1\r\n/;  # JKF rule to replace trailing \n with \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