summaryrefslogtreecommitdiff
path: root/mail
diff options
context:
space:
mode:
authorMartin Blapp <mbr@FreeBSD.org>2004-09-03 22:41:23 +0000
committerMartin Blapp <mbr@FreeBSD.org>2004-09-03 22:41:23 +0000
commitecdd8751aa8e722f759b8bcf0e68068f03cd23f0 (patch)
tree0264adf1c8d1ed80bbf9e29e743b97c6e937adc3 /mail
parentmultiple vulnerabilities in LHA (diff)
Add fix/workaround for corrupted PDF files attached as
quoted-printable encoded MIME attachments by some popular email-client versions on windows.
Notes
Notes: svn path=/head/; revision=118105
Diffstat (limited to 'mail')
-rw-r--r--mail/p5-MIME-Tools/files/patch-Decoder-qpdecode-pdf41
1 files changed, 41 insertions, 0 deletions
diff --git a/mail/p5-MIME-Tools/files/patch-Decoder-qpdecode-pdf b/mail/p5-MIME-Tools/files/patch-Decoder-qpdecode-pdf
new file mode 100644
index 000000000000..7f5da10e9bcb
--- /dev/null
+++ b/mail/p5-MIME-Tools/files/patch-Decoder-qpdecode-pdf
@@ -0,0 +1,41 @@
+--- 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($output));
++ }
+ }
+ 1;
+ }