aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog9
-rw-r--r--camel/providers/imap/camel-imap-folder.c59
2 files changed, 44 insertions, 24 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 387d9f5474..bad736e339 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,14 @@
2000-07-28 Jeffrey Stedfast <fejj@helixcode.com>
+ * providers/imap/camel-imap-folder.c (imap_expunge): Make sure
+ the third word/token (whatever) is "EXPUNGE" and not something
+ else like "EXISTS" or "RECENT". When removing the message from
+ the summary also make sure to free that data to avoid leakage.
+ Also make sure to subtract 1 from the 'id' since IMAP starts
+ at 1 and our summary starts at 0 :-)
+
+2000-07-28 Jeffrey Stedfast <fejj@helixcode.com>
+
* providers/imap/camel-imap-store.c (camel_imap_status): Cleaned
up a bit, now uses imap_next_word()
(camel_imap_command_extended): Now uses imap_next_word(). When
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 48ae72d032..954e103c8f 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -398,34 +398,44 @@ imap_expunge (CamelFolder *folder, CamelException *ex)
}
/* else we have a message id? */
- if (*word >= '0' && *word <= '9') {
+ if (*word >= '0' && *word <= '9' && !strncmp ("EXPUNGE", imap_next_word (word), 7)) {
int id;
id = atoi (word);
-
- d(fprintf (stderr, "Expunging message %d from the summary\n", id + i));
- if (id < imap_folder->summary->len) {
+ d(fprintf (stderr, "Expunging message %d from the summary (i = %d)\n", id + i, i));
+
+ if (id <= imap_folder->summary->len) {
CamelMessageInfo *info;
- info = (CamelMessageInfo *) imap_folder->summary->pdata[id];
+ info = (CamelMessageInfo *) imap_folder->summary->pdata[id - 1];
/* remove from the lookup table and summary */
g_hash_table_remove (imap_folder->summary_hash, info->uid);
- g_ptr_array_remove_index (imap_folder->summary, id);
+ g_ptr_array_remove_index (imap_folder->summary, id - 1);
+
+ /* free the info data */
+ g_free (info->subject);
+ g_free (info->from);
+ g_free (info->to);
+ g_free (info->cc);
+ g_free (info->uid);
+ g_free (info->message_id);
+ header_references_list_clear (&info->references);
+ g_free (info);
+ info = NULL;
} else {
/* Hopefully this should never happen */
d(fprintf (stderr, "imap expunge-error: message %d is out of range\n", id));
}
- } else {
- /* Huh? */
- d(fprintf (stderr, "imap expunge-warning: unexpected token: '%s'\n", word));
}
} else {
break;
}
for ( ; *node && *node != '\n'; node++);
+ if (*node)
+ node++;
}
g_free (result);
@@ -836,20 +846,20 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
status != CAMEL_IMAP_FAIL && result ? result :
"Unknown error");
g_free (result);
- return camel_mime_message_new ();
+ return NULL;
}
for (p = result; *p && *p != '{' && *p != '\n'; p++);
if (*p != '{') {
g_free (result);
- return camel_mime_message_new ();
+ return NULL;
}
part_len = atoi (p + 1);
for ( ; *p && *p != '\n'; p++);
if (*p != '\n') {
g_free (result);
- return camel_mime_message_new ();
+ return NULL;
}
/* calculate the new part-length */
@@ -884,22 +894,23 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
"Unknown error");
g_free (result);
g_free (header);
- return camel_mime_message_new ();
+ return NULL;
}
for (p = result; *p && *p != '{' && *p != '\n'; p++);
if (*p != '{') {
- g_free (result);
- g_free (header);
- return camel_mime_message_new ();
- }
-
- part_len = atoi (p + 1);
- for ( ; *p && *p != '\n'; p++);
- if (*p != '\n') {
- g_free (result);
- g_free (header);
- return camel_mime_message_new ();
+ /* this is a hack for when the part length isn't in {}'s */
+ part_len = 1;
+ for ( ; *p && *p != '\n'; p++);
+ p++;
+ } else {
+ part_len = atoi (p + 1);
+ for ( ; *p && *p != '\n'; p++);
+ if (*p != '\n') {
+ g_free (result);
+ g_free (header);
+ return NULL;
+ }
}
/* calculate the new part-length */