ietf-822
[Top] [All Lists]

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

1996-02-13 11:08:55
< Ned Freed <NED(_at_)INNOSOFT(_dot_)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(_at_)pegasus(_dot_)att(_dot_)com, 
tony(_at_)attmail(_dot_)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 {