Subject: imap-2004.RC8

From: Pete Maclean <[email-masked]>
Date: Sun, 18 Apr 2004 11:45:25 -0400

Mark,

Following your recommendation on the IMAP mailing list, I have started 
using the imap-2004 c-client code, in particular to take advantage of the 
utf8_cstext function.  I have found one bug in RC8 that needs some 
attention.  The code concerned is in the utf8_rmap function:

     case CT_1BYTE:		/* 1 byte ASCII + table 0x80-0xff */
       for (tab = (unsigned short *) cs->tab,i = 128; i < 256; i++)
	if (tab[i] != UBOGON) rmap[tab[i]] = (unsigned short) i;
       break;

I believe this should be something like:

     case CT_1BYTE:		/* 1 byte ASCII + table 0x80-0xff */
       for (tab = (unsigned short *) cs->tab,i = 0; i < 128; i++)
	if (tab[i] != UBOGON) rmap[tab[i]] = (unsigned short) (i + 128);
       break;

I also came across something in imap-2002e that I think may be a problem 
and which is unchanged in RC8.  That is that the [location] field of the 
BODY structure is never garbage collected.

Despite the problem, utf8_cstext is a godsend.  Thank you so much.

Pete Maclean

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Sun, 18 Apr 2004 09:18:43 -0700 (PDT)

Thank you Pete for reporting these problems and for your nice words!

I decided to fix utf8.c in a slightly different (but equivalent) way, and 
also fixed the body->location cleanup problem too.  See attached diffs.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.

*** mail.c	2004/04/08 23:05:05	1.52
--- mail.c	2004/04/18 16:16:03
***************
*** 10,16 ****
   *		Internet: [email-masked]
   *
   * Date:	22 November 1989
!  * Last Edited:	8 April 2004
   *
   * The IMAP toolkit provided in this Distribution is
   * Copyright 1988-2004 University of Washington.
--- 10,16 ----
   *		Internet: [email-masked]
   *
   * Date:	22 November 1989
!  * Last Edited:	18 April 2004
   *
   * The IMAP toolkit provided in this Distribution is
   * Copyright 1988-2004 University of Washington.
***************
*** 5504,5509 ****
--- 5504,5510 ----
    if (body->disposition.parameter)
      mail_free_body_parameter (&body->disposition.parameter);
    if (body->language) mail_free_stringlist (&body->language);
+   if (body->location) fs_give ((void **) &body->location);
    if (body->mime.text.data) fs_give ((void **) &body->mime.text.data);
    if (body->contents.text.data) fs_give ((void **) &body->contents.text.data);
    if (body->md5) fs_give ((void **) &body->md5);
*** utf8.c	2004/03/16 23:56:02	1.14
--- utf8.c	2004/04/18 16:16:08
***************
*** 10,16 ****
   *		Internet: [email-masked]
   *
   * Date:	11 June 1997
!  * Last Edited:	15 March 2004
   * 
   * The IMAP toolkit provided in this Distribution is
   * Copyright 1988-2004 University of Washington.
--- 10,16 ----
   *		Internet: [email-masked]
   *
   * Date:	11 June 1997
!  * Last Edited:	18 April 2004
   * 
   * The IMAP toolkit provided in this Distribution is
   * Copyright 1988-2004 University of Washington.
***************
*** 376,382 ****
        break;
      case CT_1BYTE:		/* 1 byte ASCII + table 0x80-0xff */
        for (tab = (unsigned short *) cs->tab,i = 128; i < 256; i++)
! 	if (tab[i] != UBOGON) rmap[tab[i]] = (unsigned short) i;
        break;
      case CT_1BYTE8:		/* 1 byte table 0x00 - 0xff */
        for (tab = (unsigned short *) cs->tab,i = 0; i < 256; i++)
--- 376,383 ----
        break;
      case CT_1BYTE:		/* 1 byte ASCII + table 0x80-0xff */
        for (tab = (unsigned short *) cs->tab,i = 128; i < 256; i++)
! 	if (tab[i & BITS7] != UBOGON) rmap[tab[i & BITS7]] =
! 	  (unsigned short) i;
        break;
      case CT_1BYTE8:		/* 1 byte table 0x00 - 0xff */
        for (tab = (unsigned short *) cs->tab,i = 0; i < 256; i++)