]> diplodocus.org Git - nmh/blobdiff - uip/mhparse.c
Fix a bug leading to message corruption with inc when incorporation more
[nmh] / uip / mhparse.c
index 25bbad753ab7cd923069b8d85056b675c2ee636c..39a701dbf17c6931cb726e12a71d5f6e1bf02679 100644 (file)
@@ -46,11 +46,7 @@ struct k2v SubText[] = {
     { NULL,       TEXT_UNKNOWN }    /* this one must be last! */
 };
 
     { NULL,       TEXT_UNKNOWN }    /* this one must be last! */
 };
 
-struct k2v Charset[] = {
-    { "us-ascii",   CHARSET_USASCII },
-    { "iso-8859-1", CHARSET_LATIN },
-    { NULL,         CHARSET_UNKNOWN }  /* this one must be last! */
-};
+/* Charset[] removed -- yozo.  Mon Oct  8 01:03:41 JST 2012 */
 
 /*
  * Structures for MULTIPART messages
 
 /*
  * Structures for MULTIPART messages
@@ -266,6 +262,7 @@ get_content (FILE *in, char *file, int toplevel)
     char *np, *vp;
     CT ct;
     HF hp;
     char *np, *vp;
     CT ct;
     HF hp;
+    m_getfld_state_t gstate = 0;
 
     /* allocate the content structure */
     if (!(ct = (CT) calloc (1, sizeof(*ct))))
 
     /* allocate the content structure */
     if (!(ct = (CT) calloc (1, sizeof(*ct))))
@@ -279,11 +276,11 @@ get_content (FILE *in, char *file, int toplevel)
      * Parse the header fields for this
      * content into a linked list.
      */
      * Parse the header fields for this
      * content into a linked list.
      */
-    for (compnum = 1, state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+    for (compnum = 1;;) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (&gstate, name, buf, &bufsz, in)) {
        case FLD:
        case FLDPLUS:
        case FLD:
        case FLDPLUS:
-       case FLDEOF:
            compnum++;
 
            /* get copies of the buffers */
            compnum++;
 
            /* get copies of the buffers */
@@ -292,22 +289,19 @@ get_content (FILE *in, char *file, int toplevel)
 
            /* if necessary, get rest of field */
            while (state == FLDPLUS) {
 
            /* if necessary, get rest of field */
            while (state == FLDPLUS) {
-               state = m_getfld (state, name, buf, sizeof(buf), in);
+               bufsz = sizeof buf;
+               state = m_getfld (&gstate, name, buf, &bufsz, in);
                vp = add (buf, vp);     /* add to previous value */
            }
 
            /* Now add the header data to the list */
            add_header (ct, np, vp);
 
                vp = add (buf, vp);     /* add to previous value */
            }
 
            /* Now add the header data to the list */
            add_header (ct, np, vp);
 
-           /* continue, if this isn't the last header field */
-           if (state != FLDEOF) {
-               ct->c_begin = ftell (in) + 1;
-               continue;
-           }
-           /* else fall... */
+           /* continue, to see if this isn't the last header field */
+           ct->c_begin = ftell (in) + 1;
+           continue;
 
        case BODY:
 
        case BODY:
-       case BODYEOF:
            ct->c_begin = ftell (in) - strlen (buf);
            break;
 
            ct->c_begin = ftell (in) - strlen (buf);
            break;
 
@@ -326,6 +320,7 @@ get_content (FILE *in, char *file, int toplevel)
        /* break out of the loop */
        break;
     }
        /* break out of the loop */
        break;
     }
+    m_getfld_state_destroy (&gstate);
 
     /*
      * Read the content headers.  We will parse the
 
     /*
      * Read the content headers.  We will parse the
@@ -1077,14 +1072,8 @@ InitText (CT ct)
 
     /* check if content specified a character set */
     if (*ap) {
 
     /* check if content specified a character set */
     if (*ap) {
-       /* match character set or set to CHARSET_UNKNOWN */
-       for (kv = Charset; kv->kv_key; kv++) {
-           if (!mh_strcasecmp (*ep, kv->kv_key)) {
-               chset = *ep;
-               break;
-           }
-       }
-       t->tx_charset = kv->kv_value;
+       chset = *ep;
+       t->tx_charset = CHARSET_SPECIFIED;
     } else {
        t->tx_charset = CHARSET_UNSPECIFIED;
     }
     } else {
        t->tx_charset = CHARSET_UNSPECIFIED;
     }