[exim-cvs] cvs commit: exim/exim-doc/doc-txt ChangeLog exim…

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: exim-cvs
Subject: [exim-cvs] cvs commit: exim/exim-doc/doc-txt ChangeLog exim/exim-src/src mime.c exim/exim-test/confs 4000 exim/exim-test/mail 4000.userx exim/exim-test/scripts/4000-scanning 4000
ph10 2006/09/05 16:34:41 BST

  Modified files:
    exim-doc/doc-txt     ChangeLog 
    exim-src/src         mime.c 
    exim-test/confs      4000 
    exim-test/mail       4000.userx 
    exim-test/scripts/4000-scanning 4000 
  Log:
  Nico Erfurth's patch to refactor mime.c (quoted-printable decoding).
  Added a small, simple test for quoted-printable decoding.


  Revision  Changes    Path
  1.389     +3 -0      exim/exim-doc/doc-txt/ChangeLog
  1.15      +21 -61    exim/exim-src/src/mime.c
  1.3       +4 -1      exim/exim-test/confs/4000
  1.2       +32 -8     exim/exim-test/mail/4000.userx
  1.2       +10 -0     exim/exim-test/scripts/4000-scanning/4000


  Index: ChangeLog
  ===================================================================
  RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
  retrieving revision 1.388
  retrieving revision 1.389
  diff -u -r1.388 -r1.389
  --- ChangeLog    5 Sep 2006 14:14:32 -0000    1.388
  +++ ChangeLog    5 Sep 2006 15:34:40 -0000    1.389
  @@ -1,4 +1,4 @@
  -$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.388 2006/09/05 14:14:32 ph10 Exp $
  +$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.389 2006/09/05 15:34:40 ph10 Exp $


   Change log file for Exim from version 4.21
   -------------------------------------------
  @@ -30,6 +30,9 @@
         manifest itself as EPIPE rather than ECONNECT. When tidying away a
         session, the daemon ignores ECONNECT errors and logs others; it now
         ignores EPIPE as well.
  +
  +PH/04 Applied Nico Erfurth's refactoring patch to tidy up mime.c
  +      (quoted-printable decoding).



Exim version 4.63

  Index: mime.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/mime.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- mime.c    22 Feb 2006 14:46:44 -0000    1.14
  +++ mime.c    5 Sep 2006 15:34:41 -0000    1.15
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/mime.c,v 1.14 2006/02/22 14:46:44 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/mime.c,v 1.15 2006/09/05 15:34:41 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -41,78 +41,38 @@
              0-255 - char to write
   */


  -unsigned int mime_qp_hstr_i(uschar *cptr) {
  -  unsigned int i, j = 0;
  -  while (cptr && *cptr && isxdigit(*cptr)) {
  -    i = *cptr++ - '0';
  -    if (9 < i) i -= 7;
  -    j <<= 4;
  -    j |= (i & 0x0f);
  -  }
  -  return(j);
  -}
  -
  -uschar *mime_decode_qp_char(uschar *qp_p,int *c) {
  -  uschar hex[] = {0,0,0};
  -  int nan = 0;
  +uschar *mime_decode_qp_char(uschar *qp_p, int *c) {
     uschar *initial_pos = qp_p;


     /* advance one char */
     qp_p++;


  -  REPEAT_FIRST:
  -  if ( (*qp_p == '\t') || (*qp_p == ' ') || (*qp_p == '\r') )  {
  -    /* tab or whitespace may follow
  -       just ignore it, but remember
  -       that this is not a valid hex
  -       encoding any more */
  -    nan = 1;
  +  /* Check for two hex digits and decode them */
  +  if (isxdigit(*qp_p) && isxdigit(qp_p[1])) {
  +    /* Do hex conversion */
  +    if (isdigit(*qp_p)) {*c = *qp_p - '0';}
  +    else {*c = toupper(*qp_p) - 'A' + 10;};
  +    *c <<= 4;
  +    if (isdigit(qp_p[1])) {*c |= qp_p[1] - '0';}
  +    else {*c |= toupper(qp_p[1]) - 'A' + 10;};
  +    return qp_p + 2;
  +  };
  +
  +  /* tab or whitespace may follow just ignore it if it precedes \n */
  +  while (*qp_p == '\t' || *qp_p == ' ' || *qp_p == '\r')
       qp_p++;
  -    goto REPEAT_FIRST;
  -  }
  -  else if ( (('0' <= *qp_p) && (*qp_p <= '9')) || (('A' <= *qp_p) && (*qp_p <= 'F'))  || (('a' <= *qp_p) && (*qp_p <= 'f')) ) {
  -    /* this is a valid hex char, if nan is unset */
  -    if (nan) {
  -      /* this is illegal */
  -      *c = -2;
  -      return initial_pos;
  -    }
  -    else {
  -      hex[0] = *qp_p;
  -      qp_p++;
  -    };
  -  }
  -  else if (*qp_p == '\n') {
  -    /* hit soft line break already, continue */
  +
  +  if (*qp_p == '\n') {
  +    /* hit soft line break */
       *c = -1;
       return qp_p;
  -  }
  -  else {
  -    /* illegal char here */
  -    *c = -2;
  -    return initial_pos;
     };


  -  if ( (('0' <= *qp_p) && (*qp_p <= '9')) || (('A' <= *qp_p) && (*qp_p <= 'F')) || (('a' <= *qp_p) && (*qp_p <= 'f')) ) {
  -    if (hex[0] > 0) {
  -      hex[1] = *qp_p;
  -      /* do hex conversion */
  -      *c = mime_qp_hstr_i(hex);
  -      qp_p++;
  -      return qp_p;
  -    }
  -    else {
  -      /* huh ? */
  -      *c = -2;
  -      return initial_pos;
  -    };
  -  }
  -  else {
  -    /* illegal char */
  -    *c = -2;
  -    return initial_pos;
  -  };
  +  /* illegal char here */
  +  *c = -2;
  +  return initial_pos;
   }
  +



uschar *mime_parse_line(uschar *buffer, uschar *data, uschar *encoding, int *num_decoded) {

  Index: 4000
  ===================================================================
  RCS file: /home/cvs/exim/exim-test/confs/4000,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- 4000    6 Mar 2006 16:05:12 -0000    1.2
  +++ 4000    5 Sep 2006 15:34:41 -0000    1.3
  @@ -62,7 +62,10 @@
                           X-$mime_part_count-is-rfc822: $mime_is_rfc822\n\
                           X-$mime_part_count-decode-filename: $mime_decoded_filename\n\
                           X-$mime_part_count-content-size: $mime_content_size
  -
  +  warn     mime_regex = (?s)\
  +                        (?=Test quoted-printable =)\
  +                        (?=.*?Continued line with this)
  +           add_header = X-mime-regex: matched
     accept




  Index: 4000.userx
  ===================================================================
  RCS file: /home/cvs/exim/exim-test/mail/4000.userx,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- 4000.userx    7 Feb 2006 10:34:59 -0000    1.1
  +++ 4000.userx    5 Sep 2006 15:34:41 -0000    1.2
  @@ -93,13 +93,13 @@
   X-0-is-coverletter: 1
   X-0-is-rfc822: 0
   X-0-decode-filename: TESTSUITE/spool/scan/10HmbC-0005vi-00/10HmbC-0005vi-00-00000
  -X-0-content-size: 1
  +X-0-content-size: 2
   X-1-content-type: text/plain
   X-1-filename: 
  -X-1-charset: us-ascii
  +X-1-charset: US-ASCII
   X-1-boundary: 
   X-1-content-disposition: inline
  -X-1-content-transfer-encoding: 
  +X-1-content-transfer-encoding: quoted-printable
   X-1-content-id: 
   X-1-content-description: 
   X-1-is-multipart: 0
  @@ -107,11 +107,12 @@
   X-1-is-rfc822: 0
   X-1-decode-filename: TESTSUITE/spool/scan/10HmbC-0005vi-00/10HmbC-0005vi-00-00001
   X-1-content-size: 1
  +X-mime-regex: matched
   X-2-content-type: text/plain
  -X-2-filename: working-patch
  +X-2-filename: 
   X-2-charset: us-ascii
   X-2-boundary: 
  -X-2-content-disposition: attachment
  +X-2-content-disposition: inline
   X-2-content-transfer-encoding: 
   X-2-content-id: 
   X-2-content-description: 
  @@ -121,11 +122,11 @@
   X-2-decode-filename: TESTSUITE/spool/scan/10HmbC-0005vi-00/10HmbC-0005vi-00-00002
   X-2-content-size: 1
   X-3-content-type: text/plain
  -X-3-filename: 
  +X-3-filename: working-patch
   X-3-charset: us-ascii
   X-3-boundary: 
  -X-3-content-disposition: inline
  -X-3-content-transfer-encoding: 7bit
  +X-3-content-disposition: attachment
  +X-3-content-transfer-encoding: 
   X-3-content-id: 
   X-3-content-description: 
   X-3-is-multipart: 0
  @@ -133,7 +134,30 @@
   X-3-is-rfc822: 0
   X-3-decode-filename: TESTSUITE/spool/scan/10HmbC-0005vi-00/10HmbC-0005vi-00-00003
   X-3-content-size: 1
  +X-4-content-type: text/plain
  +X-4-filename: 
  +X-4-charset: us-ascii
  +X-4-boundary: 
  +X-4-content-disposition: inline
  +X-4-content-transfer-encoding: 7bit
  +X-4-content-id: 
  +X-4-content-description: 
  +X-4-is-multipart: 0
  +X-4-is-coverletter: 0
  +X-4-is-rfc822: 0
  +X-4-decode-filename: TESTSUITE/spool/scan/10HmbC-0005vi-00/10HmbC-0005vi-00-00004
  +X-4-content-size: 1
   X-Router-SSint: was preserved
  +
  +--T4sUOijqQbZv57TR
  +Content-Type: text/plain; charset=US-ASCII
  +Content-Transfer-Encoding: quoted-printable
  +Content-Disposition: inline
  +
  +Test quoted-printable =3D    
  +Space at end of line=40
  +Continued line =    
  +with this text.


--T4sUOijqQbZv57TR
Content-Type: text/plain; charset=us-ascii

  Index: 4000
  ===================================================================
  RCS file: /home/cvs/exim/exim-test/scripts/4000-scanning/4000,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- 4000    7 Feb 2006 10:54:49 -0000    1.1
  +++ 4000    5 Sep 2006 15:34:41 -0000    1.2
  @@ -75,6 +75,16 @@
   Precedence: list


   --T4sUOijqQbZv57TR
  +Content-Type: text/plain; charset=US-ASCII
  +Content-Transfer-Encoding: quoted-printable
  +Content-Disposition: inline
  +
  +Test quoted-printable =3D    
  +Space at end of line=40
  +Continued line =    
  +with this text.
  +
  +--T4sUOijqQbZv57TR
   Content-Type: text/plain; charset=us-ascii
   Content-Disposition: inline