mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-28 05:29:48 +00:00
Add fix/workaround for corrupted PDF files attached as
quoted-printable encoded MIME attachments by some popular email-client versions on windows.
This commit is contained in:
parent
a093965a26
commit
ecdd8751aa
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=118105
41
mail/p5-MIME-Tools/files/patch-Decoder-qpdecode-pdf
Normal file
41
mail/p5-MIME-Tools/files/patch-Decoder-qpdecode-pdf
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user