X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/adc0a3232c43033729dbc036f0757bddfba463bd..524ff0f3996577fbdc0754f3a97d2c375e4c9d7e:/uip/mhparse.c diff --git a/uip/mhparse.c b/uip/mhparse.c index bf93b18e..0dcd1333 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -262,7 +262,7 @@ get_content (FILE *in, char *file, int toplevel) char *np, *vp; CT ct; HF hp; - m_getfld_state_t gstate; + m_getfld_state_t gstate = 0; /* allocate the content structure */ if (!(ct = (CT) calloc (1, sizeof(*ct)))) @@ -276,10 +276,10 @@ get_content (FILE *in, char *file, int toplevel) * Parse the header fields for this * content into a linked list. */ - m_getfld_state_init (&gstate); + m_getfld_track_filepos (&gstate, in); for (compnum = 1;;) { int bufsz = sizeof buf; - switch (state = m_getfld (gstate, name, buf, &bufsz, in)) { + switch (state = m_getfld (&gstate, name, buf, &bufsz, in)) { case FLD: case FLDPLUS: compnum++; @@ -291,7 +291,7 @@ get_content (FILE *in, char *file, int toplevel) /* if necessary, get rest of field */ while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (gstate, name, buf, &bufsz, in); + state = m_getfld (&gstate, name, buf, &bufsz, in); vp = add (buf, vp); /* add to previous value */ } @@ -1121,9 +1121,22 @@ InitMultiPart (CT ct) */ if (ct->c_encoding != CE_7BIT && ct->c_encoding != CE_8BIT && ct->c_encoding != CE_BINARY) { + /* Copy the Content-Transfer-Encoding header field body so we can + remove any trailing whitespace and leading blanks from it. */ + char *cte = add (ct->c_celine ? ct->c_celine : "(null)", NULL); + + bp = cte + strlen (cte) - 1; + while (bp >= cte && isspace (*bp)) *bp-- = '\0'; + for (bp = cte; *bp && isblank (*bp); ++bp) continue; + admonish (NULL, - "\"%s/%s\" type in message %s must be encoded in 7bit, 8bit, or binary", - ci->ci_type, ci->ci_subtype, ct->c_file); + "\"%s/%s\" type in message %s must be encoded in\n" + "7bit, 8bit, or binary, per RFC 2045 (6.4). One workaround " + "is to\nmanually edit the file and change the \"%s\"\n" + "Content-Transfer-Encoding to one of those. For now", + ci->ci_type, ci->ci_subtype, ct->c_file, bp); + free (cte); + return NOTOK; }