{
char *ptr;
char looking_for[256];
+ int double_quotes = 0;
snprintf(looking_for, sizeof looking_for, "%s=", key);
strcpy(target, (ptr + strlen(looking_for)));
for (ptr=target; (*ptr != 0); ++ptr) {
+
+ /* A semicolon means we've hit the end of the key, unless we're inside double quotes */
+ if ( (double_quotes != 1) && (*ptr == ';')) {
+ *ptr = 0;
+ }
+
+ /* if we find double quotes, we've got a great set of string boundaries */
if (*ptr == '\"') {
- strcpy(ptr, ptr+1);
+ ++double_quotes;
+ if (double_quotes == 1) {
+ strcpy(ptr, ptr+1);
+ }
+ else {
+ *ptr = 0;
+ }
}
}
}
striplt(content_type);
extract_key(content_type_name, content_type, "name");
extract_key(charset, content_type, "charset");
+ extract_key(boundary, header, "boundary");
/* Deal with weird headers */
if (strchr(content_type, ' '))
*(strchr(content_type, ' ')) = '\0';
strcpy(encoding, &header[26]);
striplt(encoding);
}
- if (strlen(boundary) == 0)
- extract_key(boundary, header, "boundary");
strcpy(header, "");
headerlen = 0;
}
*/
ch = *mptr++;
if (ch != 255) {
- lprintf(CTDL_ERR,
- "Message %ld appears to be corrupted.\n",
- msgnum);
+ lprintf(CTDL_ERR, "Message %ld appears to be corrupted.\n", msgnum);
cdb_free(dmsgtext);
return NULL;
}
* we've already printed another section, skip this one.
*/
if ( (ma->is_ma) && (ma->did_print) ) {
- lprintf(CTDL_DEBUG, "Skipping part %s (%s)\n",
- partnum, cbtype);
+ lprintf(CTDL_DEBUG, "Skipping part %s (%s)\n", partnum, cbtype);
return;
}
ma->did_print = 1;
extract_token(buf, CC->preferred_formats, i, '|', sizeof buf);
if ( (!strcasecmp(buf, cbtype)) && (!ma->freeze) ) {
if (i < ma->chosen_pref) {
+ lprintf(CTDL_DEBUG, "Setting chosen part: <%s>\n", partnum);
safestrncpy(ma->chosen_part, partnum, sizeof ma->chosen_part);
ma->chosen_pref = i;
}