Re: questions on QP, non-text attachments and munpack

hansen@pegasus.att.com Tue, 13 February 1996 18:36 UTC

Received: from ietf.nri.reston.va.us by IETF.CNRI.Reston.VA.US id aa20838; 13 Feb 96 13:36 EST
Received: from CNRI.Reston.VA.US by IETF.CNRI.Reston.VA.US id aa20833; 13 Feb 96 13:36 EST
Received: from list.cren.net by CNRI.Reston.VA.US id aa11813; 13 Feb 96 13:36 EST
Received: from localhost (localhost [127.0.0.1]) by list.cren.net (8.6.12/8.6.12) with SMTP id NAA24982; Tue, 13 Feb 1996 13:10:02 -0500
Received: from gw3.att.com (gw4.att.com [204.179.186.34]) by list.cren.net (8.6.12/8.6.12) with SMTP id NAA24959 for <ietf-822@list.cren.net>; Tue, 13 Feb 1996 13:08:55 -0500
Received: from pegasus.UUCP by ig4.att.att.com id AA02473; Tue, 13 Feb 96 13:01:34 EST
Message-Id: <9602131801.AA02473@ig4.att.att.com>
Date: Tue, 13 Feb 1996 12:39 EST
X-Orig-Sender: owner-ietf-822@list.cren.net
Sender: ietf-archive-request@IETF.CNRI.Reston.VA.US
From: hansen@pegasus.att.com
To: John Gardiner Myers <jgm+@cmu.edu>
Cc: ietf-822@list.cren.net
Subject: Re: questions on QP, non-text attachments and munpack
Content-Type: text
X-Listprocessor-Version: 8.0(beta) -- ListProcessor by CREN

< Ned Freed <NED@INNOSOFT.COM> writes:
<< It appears that munpack assumes that all use of QP is associated with
<< text.

< Munpack does have this assumption as a heuristic.  This heuristic is made
< necessary by the design requirement that munpack not require user
< configuration of which types are what.

But munpack uses a different heuristic for base64 encoding: it appears to
check to see if the content type is text and passes a flag to the base64
decoder that says whether or not CR's should be suppressed. This heuristic
works well.

The problem is that a similar flag is not being passed to the routine that
decodes quoted-printable, and subsequently CR's are being stripped that
shouldn't be.

The fix to munpack is simple: pass the same suppressCR flag to
decode.c:fromqp() that's being passed to decode.c:from64(). A patch file is
given at the end of this message.

					Tony Hansen
			  hansen@pegasus.att.com, tony@attmail.com
		    http://ourworld.compuserve.com/homepages/Tony_Hansen

----------------
The patch from the 1.5 sources:

*** decode.c.orig	Thu Feb 16 16:39:44 1995
--- decode.c	Tue Feb 13 12:50:55 1996
***************
*** 894,900
  	break;
  
      case enc_qp:
! 	fromqp(inpart, descfile, (char **)0);
  	break;
  
      case enc_base64:

--- 894,900 -----
  	break;
  
      case enc_qp:
! 	fromqp(inpart, descfile, (char **)0, 1);
  	break;
  
      case enc_base64:
***************
*** 962,968
  	break;
  
      case enc_qp:
! 	fromqp(inpart, outfile, &outputmd5);
  	break;
  
      case enc_base64:

--- 962,968 -----
  	break;
  
      case enc_qp:
! 	fromqp(inpart, outfile, &outputmd5, suppressCR);
  	break;
  
      case enc_base64:
***************
*** 1089,1095
      if (digestp) *digestp = md5contextTo64(&context);
  }
  
! fromqp(inpart, outfile, digestp)
  struct part *inpart;
  FILE *outfile;
  char **digestp;

--- 1089,1095 -----
      if (digestp) *digestp = md5contextTo64(&context);
  }
  
! fromqp(inpart, outfile, digestp, suppressCR)
  struct part *inpart;
  FILE *outfile;
  char **digestp;
***************
*** 1093,1098
  struct part *inpart;
  FILE *outfile;
  char **digestp;
  {
      int c1, c2;
      MD5_CTX context;

--- 1093,1099 -----
  struct part *inpart;
  FILE *outfile;
  char **digestp;
+ int suppressCR;
  {
      int c1, c2;
      MD5_CTX context;
***************
*** 1108,1114
  		c2 = part_getc(inpart);
  		c2 = HEXCHAR(c2);
  		c = c1<<4 | c2;
! 		if (c != '\r') putc(c, outfile);
  		if (digestp) MD5Update(&context, &c, 1);
  	    }
  	} else {

--- 1109,1115 -----
  		c2 = part_getc(inpart);
  		c2 = HEXCHAR(c2);
  		c = c1<<4 | c2;
! 	        if (!suppressCR || c != '\r') putc(c, outfile);
  		if (digestp) MD5Update(&context, &c, 1);
  	    }
  	} else {