aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap/camel-imap-folder.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-07-03 23:24:55 +0800
committerDan Winship <danw@src.gnome.org>2001-07-03 23:24:55 +0800
commit8e7eea0d261f38e22c72a9a394df6375247c8e59 (patch)
tree36aa662db902d53cc99f10e3977d0c0c6ad0d4f0 /camel/providers/imap/camel-imap-folder.c
parent4834cba289487632097ab77228d9abf4e7eb2f90 (diff)
downloadgsoc2013-evolution-8e7eea0d261f38e22c72a9a394df6375247c8e59.tar.gz
gsoc2013-evolution-8e7eea0d261f38e22c72a9a394df6375247c8e59.tar.zst
gsoc2013-evolution-8e7eea0d261f38e22c72a9a394df6375247c8e59.zip
Doh. Don't remove things from the hash table while foreach'ing it. (And
* providers/imap/camel-imap-message-cache.c (camel_imap_message_cache_clear): Doh. Don't remove things from the hash table while foreach'ing it. (And can't use foreach_remove either because we have to remove them in a weird order). Fixes #3618. * providers/imap/camel-imap-folder.c (imap_get_message): If the server returns OK from the FETCH BODY, but there's no parseable BODY response, it's probably because there's an UN-parseable BODY response, implying the message is badly formatted, MIMEwise. In that case, fall back to fetching the message as a single part. svn path=/trunk/; revision=10748
Diffstat (limited to 'camel/providers/imap/camel-imap-folder.c')
-rw-r--r--camel/providers/imap/camel-imap-folder.c55
1 files changed, 37 insertions, 18 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index c04c6cbb4c..4797d49b86 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -1423,6 +1423,26 @@ get_message (CamelImapFolder *imap_folder, const char *uid,
#define IMAP_SMALL_BODY_SIZE 5120
static CamelMimeMessage *
+get_message_simple (CamelImapFolder *imap_folder, const char *uid,
+ CamelStream *stream, CamelException *ex)
+{
+ CamelMimeMessage *msg;
+
+ if (!stream) {
+ stream = camel_imap_folder_fetch_data (imap_folder, uid, "",
+ FALSE, ex);
+ if (!stream)
+ return NULL;
+ }
+
+ msg = camel_mime_message_new ();
+ camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg),
+ stream);
+ camel_object_unref (CAMEL_OBJECT (stream));
+ return msg;
+}
+
+static CamelMimeMessage *
imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
@@ -1431,25 +1451,20 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
CamelMimeMessage *msg;
CamelStream *stream = NULL;
+ /* If the server doesn't support IMAP4rev1, or we already have
+ * the whole thing cached, fetch it in one piece.
+ */
+ if (store->server_level < IMAP_LEVEL_IMAP4REV1 ||
+ (stream = camel_imap_folder_fetch_data (imap_folder, uid, "", TRUE, NULL)))
+ return get_message_simple (imap_folder, uid, stream, ex);
+
mi = camel_folder_summary_uid (folder->summary, uid);
g_return_val_if_fail (mi != NULL, NULL);
- /* If the message is small, or the server doesn't support
- * IMAP4rev1, or we already have the whole thing cached,
- * fetch it in one piece.
- */
- if (mi->size < IMAP_SMALL_BODY_SIZE ||
- store->server_level < IMAP_LEVEL_IMAP4REV1 ||
- (stream = camel_imap_folder_fetch_data (imap_folder, uid, "", TRUE, NULL))) {
+ /* If the message is small, fetch it in one piece. */
+ if (mi->size < IMAP_SMALL_BODY_SIZE) {
camel_folder_summary_info_free (folder->summary, mi);
- if (!stream)
- stream = camel_imap_folder_fetch_data (imap_folder, uid, "", FALSE, ex);
- if (!stream)
- return NULL;
- msg = camel_mime_message_new ();
- camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream);
- camel_object_unref (CAMEL_OBJECT (stream));
- return msg;
+ return get_message_simple (imap_folder, uid, NULL, ex);
}
/* For larger messages, fetch the structure and build a message
@@ -1492,10 +1507,14 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
camel_imap_response_free (store, response);
if (!mi->content->type) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not find message body in FETCH response."));
+ /* FETCH returned OK, but we didn't parse a BODY
+ * response. Courier will return invalid BODY
+ * responses for invalidly MIMEd messages, so
+ * fall back to fetching the entire thing and
+ * let the mailer's "bad MIME" code handle it.
+ */
camel_folder_summary_info_free (folder->summary, mi);
- return NULL;
+ return get_message_simple (imap_folder, uid, NULL, ex);
}
}