92
92
static LIST *mutt_parse_references (char *s, int in_reply_to)
94
94
LIST *t, *lst = NULL;
96
char *o = NULL, *new, *at;
98
while ((s = strtok (s, " \t;")) != NULL)
98
m = mutt_extract_message_id (s, &sp);
101
* some mail clients add other garbage besides message-ids, so do a quick
102
* check to make sure this looks like a valid message-id
103
* some idiotic clients also break their message-ids between lines, deal
104
* with that too (give up if it's more than two lines, though)
119
new = safe_strdup (s);
126
new = safe_malloc (sizeof (char) * (n + m + 1));
127
strcpy (new, o); /* __STRCPY_CHECKED__ */
128
strcpy (new + n, s); /* __STRCPY_CHECKED__ */
133
/* make sure that this really does look like a message-id.
134
* it should have exactly one @, and if we're looking at
135
* an in-reply-to header, make sure that the part before
136
* the @ has more than eight characters or it's probably
139
if (!(at = strchr (new, '@')) || strchr (at + 1, '@')
140
|| (in_reply_to && at - new <= 8))
144
t = (LIST *) safe_malloc (sizeof (LIST));
101
t = safe_malloc (sizeof (LIST));
106
m = mutt_extract_message_id (NULL, &sp);
157
112
int mutt_check_encoding (const char *c)
341
296
/* Some pre-RFC1521 gateways still use the "name=filename" convention,
342
297
* but if a filename has already been set in the content-disposition,
343
298
* let that take precedence, and don't set it here */
344
if ((pc = mutt_get_parameter( "name", ct->parameter)) != 0 && !ct->filename)
299
if ((pc = mutt_get_parameter( "name", ct->parameter)) && !ct->filename)
345
300
ct->filename = safe_strdup(pc);
347
302
#ifdef SUN_ATTACHMENT
348
303
/* this is deep and utter perversion */
349
if ((pc = mutt_get_parameter ("conversions", ct->parameter)) != 0)
304
if ((pc = mutt_get_parameter ("conversions", ct->parameter)))
350
305
ct->encoding = mutt_check_encoding (pc);
428
if ((s = mutt_get_parameter ("filename", (parms = parse_parameters (s)))) != 0)
383
if ((s = mutt_get_parameter ("filename", (parms = parse_parameters (s)))))
429
384
mutt_str_replace (&ct->filename, s);
430
if ((s = mutt_get_parameter ("name", parms)) != 0)
385
if ((s = mutt_get_parameter ("name", parms)))
431
386
ct->form_name = safe_strdup (s);
432
387
mutt_free_parameter (&parms);
925
880
return (mutt_mktime (&tm, 0) + tz_offset);
928
/* extract the first substring that looks like a message-id */
929
char *mutt_extract_message_id (const char *s)
883
/* extract the first substring that looks like a message-id.
884
* call back with NULL for more (like strtok).
886
char *mutt_extract_message_id (const char *s, const char **saveptr)
935
if ((s = strchr (s, '<')) == NULL || (p = strchr (s, '>')) == NULL)
937
l = (size_t)(p - s) + 1;
938
r = safe_malloc (l + 1);
888
const char *o, *onull, *p;
898
for (s = NULL, o = NULL, onull = NULL;
899
(p = strpbrk (p, "<> \t;")) != NULL; ++p)
913
size_t olen = onull - o, slen = p - s + 1;
914
ret = safe_malloc (olen + slen + 1);
916
memcpy (ret, o, olen);
917
memcpy (ret + olen, s, slen);
918
ret[olen + slen] = '\0';
920
*saveptr = p + 1; /* next call starts after '>' */
924
/* some idiotic clients break their message-ids between lines */
926
/* step past another whitespace */
929
/* more than two lines, give up */
930
s = o = onull = NULL;
933
/* remember the first line, start looking for the second */
944
943
void mutt_parse_mime_message (CONTEXT *ctx, HEADER *cur)
1133
1132
/* We add a new "Message-ID:" when building a message */
1134
1133
FREE (&e->message_id);
1135
e->message_id = mutt_extract_message_id (p);
1134
e->message_id = mutt_extract_message_id (p, NULL);
1138
1137
else if (!ascii_strncasecmp (line + 1, "ail-", 4))
1487
1486
/* Compares mime types to the ok and except lists */
1488
int count_body_parts_check(LIST **checklist, BODY *b, int dflt)
1487
static int count_body_parts_check(LIST **checklist, BODY *b, int dflt)
1491
1490
ATTACH_MATCH *a;
1521
1520
#define AT_COUNT(why) { shallcount = 1; }
1522
1521
#define AT_NOCOUNT(why) { shallcount = 0; }
1524
int count_body_parts (BODY *body, int flags)
1523
static int count_body_parts (BODY *body, int flags)
1527
1526
int shallcount, shallrecurse;
1601
1600
bp->attach_qualifies = shallcount ? 1 : 0;
1603
dprint(5, (debugfile, "cbp: %08x shallcount = %d\n", (unsigned int)bp, shallcount));
1602
dprint(5, (debugfile, "cbp: %p shallcount = %d\n", (void *)bp, shallcount));
1605
1604
if (shallrecurse)
1607
dprint(5, (debugfile, "cbp: %08x pre count = %d\n", (unsigned int)bp, count));
1606
dprint(5, (debugfile, "cbp: %p pre count = %d\n", (void *)bp, count));
1608
1607
bp->attach_count = count_body_parts(bp->parts, flags & ~M_PARTS_TOPLEVEL);
1609
1608
count += bp->attach_count;
1610
dprint(5, (debugfile, "cbp: %08x post count = %d\n", (unsigned int)bp, count));
1609
dprint(5, (debugfile, "cbp: %p post count = %d\n", (void *)bp, count));