X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/529d160079ee9817df9c4ca8fb49ad4304e80169..b7f1c786ed9b2ad799e5cc85ede0aa213bece0bd:/uip/mhfixmsg.c diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 2c4ef369..f80ff9be 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -1887,9 +1887,20 @@ fix_always (CT ct, int *message_mods) { for (hf = ct->c_first_hf; hf; hf = hf->next) { size_t len = strlen (hf->value); + if (strcasecmp (hf->name, TYPE_FIELD) != 0 && + strcasecmp (hf->name, DISPO_FIELD) != 0) { + /* Only do this for Content-Type and + Content-Disposition fields because those are the + only headers that parse_mime() warns about. */ + continue; + } + /* whitespace following a trailing ';' will be nuked as well */ - if (hf->value[len - 1] == '\n') - while (isspace(hf->value[len - 2])) len--; + if (hf->value[len - 1] == '\n') { + while (isspace((unsigned char)(hf->value[len - 2]))) { + if (len-- == 0) { break; } + } + } if (hf->value[len - 2] == ';') { /* Remove trailing ';' from parameter value. */ @@ -1899,10 +1910,13 @@ fix_always (CT ct, int *message_mods) { /* Also, if Content-Type parameter, remove trailing ';' from ct->c_ctline. This probably isn't necessary but can't hurt. */ - if (strcasecmp(hf->name, "Content-Type") == 0 && ct->c_ctline) { + if (strcasecmp(hf->name, TYPE_FIELD) == 0 && ct->c_ctline) { size_t l = strlen(ct->c_ctline) - 1; - while (isspace(ct->c_ctline[l]) || ct->c_ctline[l] == ';') + while (isspace((unsigned char)(ct->c_ctline[l])) || + ct->c_ctline[l] == ';') { ct->c_ctline[l--] = '\0'; + if (l == 0) { break; } + } } ++*message_mods;