dovecot-1.0: Add a context structure to all message parts and re...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Dec 21 23:04:21 EET 2007
details: http://hg.dovecot.org/dovecot-1.0/rev/3b73d3e68865
changeset: 5495:3b73d3e68865
user: Timo Sirainen <tss at iki.fi>
date: Fri Dec 21 23:04:17 2007 +0200
description:
Add a context structure to all message parts and remove the NULL checks.
That way instead of returning a broken reply, imap_bodystructure_write()
crashes if caller tries to give it non-parsed MIME parts.
diffstat:
1 file changed, 10 insertions(+), 19 deletions(-)
src/lib-imap/imap-bodystructure.c | 29 ++++++++++-------------------
diffs (67 lines):
diff -r 822d66b19b04 -r 3b73d3e68865 src/lib-imap/imap-bodystructure.c
--- a/src/lib-imap/imap-bodystructure.c Fri Dec 21 17:11:16 2007 +0200
+++ b/src/lib-imap/imap-bodystructure.c Fri Dec 21 23:04:17 2007 +0200
@@ -223,9 +223,15 @@ void imap_bodystructure_parse_header(poo
bool parent_rfc822;
if (hdr == NULL) {
- /* If there was no Mime-Version, forget all the Content-stuff */
- if ((part->flags & MESSAGE_PART_FLAG_IS_MIME) == 0 &&
- part->context != NULL) {
+ if (part->context == NULL) {
+ /* no Content-* headers. add an empty context
+ structure anyway. */
+ part->context = part_data =
+ p_new(pool, struct message_part_body_data, 1);
+ part_data->pool = pool;
+ } else if ((part->flags & MESSAGE_PART_FLAG_IS_MIME) == 0) {
+ /* If there was no Mime-Version, forget all
+ the Content-stuff */
part_data = part->context;
envelope = part_data->envelope;
@@ -267,11 +273,6 @@ static void part_write_body_multipart(st
string_t *str, bool extended)
{
struct message_part_body_data *data = part->context;
-
- if (data == NULL) {
- /* there was no content headers, use an empty structure */
- data = t_new(struct message_part_body_data, 1);
- }
if (part->children != NULL)
imap_bodystructure_write(part->children, str, extended);
@@ -334,11 +335,6 @@ static void part_write_body(struct messa
{
struct message_part_body_data *data = part->context;
bool text;
-
- if (data == NULL) {
- /* there was no content headers, use an empty structure */
- data = t_new(struct message_part_body_data, 1);
- }
if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) {
str_append(str, "\"message\" \"rfc822\"");
@@ -392,7 +388,7 @@ static void part_write_body(struct messa
i_assert(part->children->next == NULL);
child_data = part->children->context;
- env_data = child_data != NULL ? child_data->envelope : NULL;
+ env_data = child_data->envelope;
str_append(str, " (");
imap_envelope_write_part_data(env_data, str);
@@ -446,11 +442,6 @@ bool imap_bodystructure_is_plain_7bit(st
struct message_part_body_data *data = part->context;
i_assert(part->parent == NULL);
-
- if (data == NULL) {
- /* no bodystructure headers found */
- return TRUE;
- }
/* if content-type is text/xxx we don't have to check any
multipart stuff */
More information about the dovecot-cvs
mailing list