[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Increase of un-usable PDF usage.



Mike Mestnik wrote:
Over the past few mouths I've received more unusable PDFs then I've
ever received usable PDFs.
... snip
I have asked senders to choose a better format, but they keep coming.
Many sites that have PDFs as part of there content do not seam to be
having this problem it's when I get PDFs send via email that there are
issues.
...snip

I have seen windows mail-clients abusing MIME in a way that makes unix decoders do unsavory things with line-end characters in binary attachments. I don't remember the details, but if you can compare a bad pdf with the original (get it on a direct download or on a memory-stick) you'll quickly see the badness. (See cmp(1)).

Anyway, if the differences are all in missing and/or mangled CR or LF characters, check the source of the email. to see what encoding is used. I know for a fact that munpack (from the mpack package) will assume text mode if the encoding is quoted printable.

I ended up patching munpack to dissuade it from that assumption. Search for \r in the sources to find where you need to patch it. I believe they are refusing to "fix" this behaviour upstream because QP is not supposed to be used for anything but text. Maybe other mail-clients ar similarly

The version I was working on was different from the one I have now (debian testing), but I believe changing decode.c , function fromqp to accept the suppressCR argument like from64 does, and changing the calls of fromqp accordingly, would fix it. Something along the lines of the attached UNTESTED patch should do it.

NOTE the patch is UNTESTED!!

--
Håkon Alstadheim


--- decode.c.orig	2008-07-02 14:00:43.000000000 +0200
+++ decode.c	2008-07-02 14:16:35.000000000 +0200
@@ -62,7 +62,7 @@
 char *getParam(params cParams, char *key);
 char *getDispositionFilename(char *disposition);
 void from64(struct part *inpart, FILE *outfile, char **digestp, int suppressCR);
-void fromqp(struct part *inpart, FILE *outfile, char **digestp);
+void fromqp(struct part *inpart, FILE *outfile, char **digestp, int suppressCR);
 void fromnone(struct part *inpart, FILE *outfile, char **digestp);
 int handlePartial(struct part *inpart, char *headers, params contentParams,
 		  int extractText);
@@ -905,7 +905,7 @@
 	break;
 
     case enc_qp:
-	fromqp(inpart, descfile, (char **)0);
+        fromqp(inpart, descfile, (char **)0, 1);
 	break;
 
     case enc_base64:
@@ -966,7 +966,7 @@
 	break;
 
     case enc_qp:
-	fromqp(inpart, outfile, &outputmd5);
+	fromqp(inpart, outfile, &outputmd5, suppressCR);
 	break;
 
     case enc_base64:
@@ -1089,7 +1089,7 @@
     if (digestp) *digestp = md5contextTo64(&context);
 }
 
-void fromqp(struct part *inpart, FILE *outfile, char **digestp)
+void fromqp(struct part *inpart, FILE *outfile, char **digestp, suppressCR)
 {
     int c1, c2;
     MD5_CTX context;
@@ -1105,7 +1105,7 @@
 		c2 = part_getc(inpart);
 		c2 = HEXCHAR(c2);
 		c = c1<<4 | c2;
-		if (c != '\r') putc(c, outfile);
+		if (!suppressCR || c != '\r') putc(c, outfile);
 		if (digestp) MD5Update(&context, &c, 1);
 	    }
 	} else {

Reply to: