fix IMAP regression.
use a lot more mime_which_token
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
b->parts = mutt_parse_multipart(s->fpin,
parameter_getval(a->parameter, "boundary"),
(long)st.st_size,
- !ascii_strcasecmp("digest", a->subtype));
+ mime_which_token(a->subtype, -1) == MIME_DIGEST);
}
else
b = a;
b = a;
while (b) {
if (b->type == TYPETEXT) {
- if (!ascii_strcasecmp ("plain", b->subtype) && type <= TXTPLAIN) {
- choice = b;
- type = TXTPLAIN;
- }
- else if (!ascii_strcasecmp ("enriched", b->subtype)
- && type <= TXTENRICHED) {
- choice = b;
- type = TXTENRICHED;
- }
- else if (!ascii_strcasecmp ("html", b->subtype) && type <= TXTHTML) {
- choice = b;
- type = TXTHTML;
+ switch (mime_which_token(b->subtype, -1)) {
+ case MIME_PLAIN:
+ if (type <= TXTPLAIN) {
+ choice = b;
+ type = TXTPLAIN;
+ }
+ break;
+ case MIME_ENRICHED:
+ if (type <= TXTENRICHED) {
+ choice = b;
+ type = TXTENRICHED;
+ }
+ break;
+ case MIME_HTML:
+ if (type <= TXTHTML) {
+ choice = b;
+ type = TXTHTML;
+ }
+ break;
+ default:
+ break;
}
}
b = b->next;
return (1);
else if (a->type == TYPEMULTIPART) {
BODY *p;
+ int tok = mime_which_token(a->subtype, -1);
- if (ascii_strcasecmp (a->subtype, "signed") == 0 ||
- ascii_strcasecmp (a->subtype, "encrypted") == 0)
- return (1);
+ if (tok == MIME_SIGNED || tok == MIME_ENCRYPTED)
+ return 1;
for (p = a->parts; p; p = p->next) {
if (mutt_can_decode (p))
return (1);
}
-
}
else if (a->type == TYPEAPPLICATION) {
if (mutt_is_application_pgp(a))
b->parts = mutt_parse_multipart(s->fpin,
parameter_getval(a->parameter, "boundary"),
(long)st.st_size,
- !ascii_strcasecmp("digest", a->subtype));
- }
- else
+ mime_which_token(a->subtype, -1) == MIME_DIGEST);
+ } else {
b = a;
+ }
for (p = b->parts, count = 1; p; p = p->next, count++) {
if (s->flags & M_DISPLAY) {
else
expire = -1;
- if (!ascii_strcasecmp (access_type, "x-mutt-deleted")) {
+ if (mime_which_token(access_type, -1) == MIME_X_MUTT_DELETED) {
if (s->flags & (M_DISPLAY | M_PRINTING)) {
char *length;
char pretty_size[10];
int rc = 0;
int oflags = s->flags;
+ int tok = mime_which_token(b->subtype, -1);
/* first determine which handler to use to process this part */
rfc1524_entry_delete(&entry);
}
else if (b->type == TYPETEXT) {
- if (ascii_strcasecmp ("plain", b->subtype) == 0) {
+ if (tok == MIME_PLAIN) {
/* avoid copying this part twice since removing the transfer-encoding is
* the only operation needed.
*/
else
plaintext = 1;
}
- else if (ascii_strcasecmp ("enriched", b->subtype) == 0)
+ else if (tok == MIME_ENRICHED)
handler = text_enriched_handler;
else /* text body type without a handler */
plaintext = 1;
else if (b->type == TYPEMESSAGE) {
if (mutt_is_message_type (b))
handler = message_handler;
- else if (!ascii_strcasecmp ("delivery-status", b->subtype))
+ else if (tok == MIME_DELIVERY_STATUS)
plaintext = 1;
- else if (!ascii_strcasecmp ("external-body", b->subtype))
+ else if (tok == MIME_EXTERNAL_BODY)
handler = external_body_handler;
}
else if (b->type == TYPEMULTIPART) {
char *p;
- if (ascii_strcasecmp ("alternative", b->subtype) == 0)
+ if (tok == MIME_ALTERNATIVE)
handler = alternative_handler;
- else if (ascii_strcasecmp ("signed", b->subtype) == 0) {
+ else if (tok == MIME_SIGNED) {
p = parameter_getval(b->parameter, "protocol");
if (!p)
else if (s->flags & M_VERIFY)
handler = mutt_signed_handler;
}
- else if (m_strcasecmp("encrypted", b->subtype) == 0) {
+ else if (tok == MIME_ENCRYPTED) {
p = parameter_getval(b->parameter, "protocol");
if (!p)
- mutt_error (_
- ("Error: multipart/encrypted has no protocol parameter!"));
-
- else if (ascii_strcasecmp ("application/pgp-encrypted", p) == 0)
+ mutt_error(_("Error: multipart/encrypted has no protocol parameter!"));
+ else if (tok == MIME_APPLICATION_PGP_ENCRYPTED)
handler = crypt_pgp_encrypted_handler;
}
handler = crypt_smime_application_smime_handler;
}
-
if (plaintext || handler) {
fseeko (s->fpin, b->offset, 0);
* than getting the delim wrong */
idata->delim = '/';
- imap_cmd_start (idata, "string_list_t \"\" \"\"");
+ imap_cmd_start (idata, "LIST\"\" \"\"");
do {
if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
break;
s = imap_next_word (idata->cmd.buf);
- if (ascii_strncasecmp ("string_list_t", s, 4) == 0) {
+ if (ascii_strncasecmp ("LIST", s, 4) == 0) {
s = imap_next_word (s);
s = imap_next_word (s);
if (s && s[0] == '\"' && s[1] && s[2] == '\"')
apparently-from
apparently-to
application
-application/postscript
application/pgp-encrypted
application/pgp-signature
application/pkcs7-signature
+application/postscript
application/x-pkcs7-signature
audio
base64
external-body
followup-to
from
+html
image
in-reply-to
iso-2022-jp
x-comment-to
x-convert
x-label
+x-mutt-deleted
x-pgp-message
x-pkcs7-mime
xref
static void process_user_recips (ENVELOPE * env)
{
- string_list_t *uh = UserHeader;
+ string_list_t *uh = UserHeader;
- for (; uh; uh = uh->next) {
- if (ascii_strncasecmp ("to:", uh->data, 3) == 0)
- env->to = rfc822_parse_adrlist (env->to, uh->data + 3);
- else if (ascii_strncasecmp ("cc:", uh->data, 3) == 0)
- env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
- else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
- env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
+ for (; uh; uh = uh->next) {
+ const char *p = strchr(uh->data, ':');
+ if (!p)
+ continue;
+
+ switch (mime_which_token(uh->data, p - uh->data)) {
+ case MIME_TO:
+ env->to = rfc822_parse_adrlist(env->to, p);
+ break;
+ case MIME_CC:
+ env->cc = rfc822_parse_adrlist(env->cc, p);
+ break;
+ case MIME_BCC:
+ env->bcc = rfc822_parse_adrlist(env->bcc, p);
+ break;
#ifdef USE_NNTP
- else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
- env->newsgroups = nntp_get_header (uh->data + 11);
- else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
- env->followup_to = nntp_get_header (uh->data + 12);
- else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
- env->x_comment_to = nntp_get_header (uh->data + 13);
+ case MIME_NEWSGROUPS:
+ env->newsgroups = nntp_get_header(p);
+ break;
+ case MIME_FOLLOWUP_TO:
+ env->followup_to = nntp_get_header(p);
+ break;
+ case MIME_X_COMMENT_TO:
+ env->x_comment_to = nntp_get_header(p);
+ break;
#endif
- }
+ default: break;
+ }
+ }
}
-static void process_user_header (ENVELOPE * env)
+static void process_user_header(ENVELOPE * env)
{
- string_list_t *uh = UserHeader;
- string_list_t *last = env->userhdrs;
-
- if (last)
- while (last->next)
- last = last->next;
-
- for (; uh; uh = uh->next) {
- if (ascii_strncasecmp ("from:", uh->data, 5) == 0) {
- /* User has specified a default From: address. Remove default address */
- address_list_wipe(&env->from);
- env->from = rfc822_parse_adrlist (env->from, uh->data + 5);
- }
- else if (ascii_strncasecmp ("reply-to:", uh->data, 9) == 0) {
- address_list_wipe(&env->reply_to);
- env->reply_to = rfc822_parse_adrlist (env->reply_to, uh->data + 9);
- }
- else if (ascii_strncasecmp ("message-id:", uh->data, 11) == 0)
- m_strreplace(&env->message_id, uh->data + 11);
- else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
- ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
- ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
+ string_list_t *uh;
+ string_list_t **last = string_list_last(&env->userhdrs);
+
+ for (uh = UserHeader; uh; uh = uh->next) {
+ const char *p = strchr(uh->data, ':');
+
+ switch (mime_which_token(uh->data, (p ?: uh->data) - uh->data)) {
+ case MIME_FROM:
+ /* User has specified a default From: address. Remove default address */
+ address_list_wipe(&env->from);
+ env->from = rfc822_parse_adrlist(env->from, p);
+ break;
+
+ case MIME_REPLY_TO:
+ address_list_wipe(&env->reply_to);
+ env->reply_to = rfc822_parse_adrlist (env->reply_to, p);
+ break;
+
+ case MIME_MESSAGE_ID:
+ m_strreplace(&env->message_id, p);
+ break;
+
+ case MIME_TO:
+ case MIME_CC:
+ case MIME_BCC:
#ifdef USE_NNTP
- ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
- ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
- ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
+ case MIME_NEWSGROUPS:
+ case MIME_FOLLOWUP_TO:
+ case MIME_X_COMMENT_TO:
#endif
- ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
- ascii_strncasecmp ("subject:", uh->data, 8) != 0) {
- if (last) {
- last->next = string_item_new();
- last = last->next;
- }
- else
- last = env->userhdrs = string_item_new();
- last->data = m_strdup(uh->data);
+ case MIME_SUPERSEDES:
+ case MIME_SUPERCEDES:
+ case MIME_SUBJECT:
+ break;
+
+ default:
+ *last = string_item_new();
+ (*last)->data = m_strdup(uh->data);
+ last = &(*last)->next;
+ break;
+ }
}
- }
}
void mutt_forward_intro (FILE * fp, HEADER * cur)