text stringlengths 0 357 |
|---|
if (childmime!=skip_part) { |
if (dc_mimeparser_parse_mime_recursive(mimeparser, childmime)) { |
any_part_added = 1; |
} |
} |
} |
} |
break; |
} |
break; |
case MAILMIME_MESSAGE: |
if (mimeparser->header_root==NULL) |
{ |
mimeparser->header_root = mime->mm_data.mm_message.mm_fields; |
hash_header(&mimeparser->header, mimeparser->header_root, mimeparser->context); |
} |
if (mime->mm_data.mm_message.mm_msg_mime) |
{ |
any_part_added = dc_mimeparser_parse_mime_recursive(mimeparser, mime->mm_data.mm_message.mm_msg_mime); |
} |
break; |
} |
return any_part_added; |
} |
static void hash_header(dc_hash_t* out, const struct mailimf_fields* in, dc_context_t* context) |
{ |
if (NULL==in) { |
return; |
} |
for (clistiter* cur1=clist_begin(in->fld_list); cur1!=NULL ; cur1=clist_next(cur1)) |
{ |
struct mailimf_field* field = (struct mailimf_field*)clist_content(cur1); |
const char *key = NULL; |
switch (field->fld_type) |
{ |
case MAILIMF_FIELD_RETURN_PATH: key = "Return-Path"; break; |
case MAILIMF_FIELD_ORIG_DATE: key = "Date"; break; |
case MAILIMF_FIELD_FROM: key = "From"; break; |
case MAILIMF_FIELD_SENDER: key = "Sender"; break; |
case MAILIMF_FIELD_REPLY_TO: key = "Reply-To"; break; |
case MAILIMF_FIELD_TO: key = "To"; break; |
case MAILIMF_FIELD_CC: key = "Cc"; break; |
case MAILIMF_FIELD_BCC: key = "Bcc"; break; |
case MAILIMF_FIELD_MESSAGE_ID: key = "Message-ID"; break; |
case MAILIMF_FIELD_IN_REPLY_TO: key = "In-Reply-To"; break; |
case MAILIMF_FIELD_REFERENCES: key = "References"; break; |
case MAILIMF_FIELD_SUBJECT: key = "Subject"; break; |
case MAILIMF_FIELD_OPTIONAL_FIELD: |
{ |
const struct mailimf_optional_field* optional_field = field->fld_data.fld_optional_field; |
if (optional_field) { |
key = optional_field->fld_name; |
} |
} |
break; |
} |
if (key) |
{ |
int key_len = strlen(key); |
if (dc_hash_find(out, key, key_len)) |
{ |
/* key already in hash, do only overwrite known types */ |
if (field->fld_type!=MAILIMF_FIELD_OPTIONAL_FIELD |
|| (key_len>5 && strncasecmp(key, "Chat-", 5)==0)) |
{ |
//dc_log_info(context, 0, "Protected headers: Overwriting \"%s\".", key); |
dc_hash_insert(out, key, key_len, field); |
} |
} |
else |
{ |
/* key not hashed before */ |
dc_hash_insert(out, key, key_len, field); |
} |
} |
} |
} |
/** |
* Parse raw MIME-data into a MIME-object. |
* |
* You may call this function several times on the same object; old data are cleared using |
* dc_mimeparser_empty() before parsing is started. |
* |
* After dc_mimeparser_parse() is called successfully, all the functions to get information about the |
* MIME-structure will work. |
* |
* @private @memberof dc_mimeparser_t |
* @param mimeparser The MIME-parser object. |
* @param body_not_terminated Plain text, no need to be null-terminated. |
* @param body_bytes The number of bytes to read from body_not_terminated. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.