diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-11-30 23:38:17 +0000 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-11-30 23:38:17 +0000 |
commit | 5deaa1d39213c0beaf160b4b9e91e8f60fff4aff (patch) | |
tree | f5c6e745aca1ff5510428deb1fc40eb705def0b7 | |
parent | 8de87e9694a3586e80ff4bd8b6a94ec149b99b53 (diff) | |
download | evolution-data-server-5deaa1d39213c0beaf160b4b9e91e8f60fff4aff.tar.gz |
Don't use regex matching. Fixes bug #16227.
2001-11-29 Jeffrey Stedfast <fejj@ximian.com>
* camel-folder-search.c (search_body_contains): Don't use regex
matching. Fixes bug #16227.
* camel-mime-message.c (best_encoding): Check the content-object's
mime type, not the mime part types. Should fix bug #15843.
2001-11-27 Jeffrey Stedfast <fejj@ximian.com>
* providers/imap/camel-imap-folder.c (get_content): Return NULL if
construct_from_stream fails.
(get_message): Same.
(get_message_simple): Here too.
(add_message_from_data): And here.
-rw-r--r-- | camel/ChangeLog | 16 | ||||
-rw-r--r-- | camel/camel-folder-search.c | 4 | ||||
-rw-r--r-- | camel/camel-mime-message.c | 10 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 75 |
4 files changed, 74 insertions, 31 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index a984a09f2..7633b4f65 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,19 @@ +2001-11-29 Jeffrey Stedfast <fejj@ximian.com> + + * camel-folder-search.c (search_body_contains): Don't use regex + matching. Fixes bug #16227. + + * camel-mime-message.c (best_encoding): Check the content-object's + mime type, not the mime part types. Should fix bug #15843. + +2001-11-27 Jeffrey Stedfast <fejj@ximian.com> + + * providers/imap/camel-imap-folder.c (get_content): Return NULL if + construct_from_stream fails. + (get_message): Same. + (get_message_simple): Here too. + (add_message_from_data): And here. + 2001-11-14 <NotZed@Ximian.com> * camel-vee-folder.c (folder_changed_remove_uid): Use the uid diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c index d8779d08a..993de4080 100644 --- a/camel/camel-folder-search.c +++ b/camel/camel-folder-search.c @@ -752,7 +752,7 @@ search_body_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, Cam } } else if (search->folder) { /* we do a 'slow' direct search */ - if (camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE, argc, argv, search->priv->ex) == 0) { + if (camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_ICASE, argc, argv, search->priv->ex) == 0) { truth = match_message(search->folder, camel_message_info_uid(search->current), &pattern, search->priv->ex); regfree(&pattern); } @@ -802,7 +802,7 @@ search_body_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, Cam } else if (search->folder) { /* do a slow search */ r->value.ptrarray = g_ptr_array_new(); - if (camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE, argc, argv, search->priv->ex) == 0) { + if (camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_ICASE, argc, argv, search->priv->ex) == 0) { if (search->summary) { for (i=0;i<search->summary->len;i++) { CamelMessageInfo *info = g_ptr_array_index(search->summary, i); diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index 62d57bea7..b9655bec7 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -799,12 +799,16 @@ static gboolean best_encoding (CamelMimeMessage *msg, CamelMimePart *part, void *datap) { struct _enc_data *data = datap; - char *charset; CamelMimePartEncodingType encoding; + CamelDataWrapper *wrapper; + char *charset; + + wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); + if (!wrapper) + return FALSE; /* we only care about actual content objects */ - if (!CAMEL_IS_MULTIPART (part) && !CAMEL_IS_MIME_MESSAGE (part)) { - + if (!CAMEL_IS_MULTIPART (wrapper) && !CAMEL_IS_MIME_MESSAGE (wrapper)) { encoding = find_best_encoding (part, data->required, data->enctype, &charset); /* we always set the encoding, if we got this far. GET_CHARSET implies also GET_ENCODING */ diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 768f67dcf..e32d1696d 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -1015,12 +1015,12 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message, CamelImapResponse *response; char *uid; int count; - + count = camel_folder_summary_count (folder->summary); response = do_append (folder, message, info, &uid, ex); if (!response) return; - + if (uid) { /* Cache first, since freeing response may trigger a * summary update that will want this information. @@ -1032,9 +1032,9 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message, CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock); g_free (uid); } - + camel_imap_response_free (store, response); - + /* Make sure a "folder_changed" is emitted. */ if (store->current_folder != folder || camel_folder_summary_count (folder->summary) == count) @@ -1048,24 +1048,24 @@ imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message, CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store); CamelImapResponse *response; char *uid; - + response = do_append (folder, message, info, &uid, ex); if (!response) return; - + if (uid) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); const char *olduid = camel_message_info_uid (info); - + CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); camel_imap_message_cache_copy (imap_folder->cache, olduid, imap_folder->cache, uid, ex); CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); - + camel_disco_diary_uidmap_add (CAMEL_DISCO_STORE (store)->diary, olduid, uid); } - + camel_imap_response_free (store, response); } @@ -1401,33 +1401,42 @@ get_content (CamelImapFolder *imap_folder, const char *uid, CamelDataWrapper *content = NULL; CamelStream *stream; char *child_spec; - + /* There are three cases: multipart, message/rfc822, and "other" */ - + if (header_content_type_is (ci->type, "multipart", "*")) { CamelMultipart *body_mp; int speclen, num; - + body_mp = camel_multipart_new (); camel_data_wrapper_set_mime_type_field ( CAMEL_DATA_WRAPPER (body_mp), ci->type); camel_multipart_set_boundary (body_mp, NULL); - + speclen = strlen (part_spec); child_spec = g_malloc (speclen + 15); memcpy (child_spec, part_spec, speclen); if (speclen > 0) child_spec[speclen++] = '.'; - + ci = ci->childs; num = 1; while (ci) { sprintf (child_spec + speclen, "%d.MIME", num++); stream = camel_imap_folder_fetch_data (imap_folder, uid, child_spec, FALSE, ex); if (stream) { + int ret; + part = camel_mime_part_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (part), stream); + ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (part), stream); camel_object_unref (CAMEL_OBJECT (stream)); + if (ret == -1) { + camel_object_unref (CAMEL_OBJECT (part)); + camel_object_unref (CAMEL_OBJECT (body_mp)); + g_free (child_spec); + return NULL; + } + *(strchr (child_spec + speclen, '.')) = '\0'; content = get_content (imap_folder, uid, child_spec, part, ci, ex); } @@ -1436,7 +1445,7 @@ get_content (CamelImapFolder *imap_folder, const char *uid, camel_object_unref (CAMEL_OBJECT (body_mp)); return NULL; } - + camel_medium_set_content_object (CAMEL_MEDIUM (part), content); camel_object_unref (CAMEL_OBJECT (content)); camel_multipart_add_part (body_mp, part); @@ -1472,6 +1481,7 @@ get_message (CamelImapFolder *imap_folder, const char *uid, CamelMimeMessage *msg; CamelStream *stream; char *section_text; + int ret; section_text = g_strdup_printf ("%s%s%s", part_spec, *part_spec ? "." : "", store->server_level >= IMAP_LEVEL_IMAP4REV1 ? "HEADER" : "0"); @@ -1481,8 +1491,12 @@ get_message (CamelImapFolder *imap_folder, const char *uid, return NULL; msg = camel_mime_message_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream); + ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream); camel_object_unref (CAMEL_OBJECT (stream)); + if (ret == -1) { + camel_object_unref (CAMEL_OBJECT (msg)); + return NULL; + } content = get_content (imap_folder, uid, part_spec, CAMEL_MIME_PART (msg), ci, ex); if (!content) { @@ -1506,7 +1520,8 @@ get_message_simple (CamelImapFolder *imap_folder, const char *uid, CamelMimeMessage *msg; CamelImapStore *imap_store = CAMEL_IMAP_STORE (CAMEL_FOLDER (imap_folder)->parent_store); - + int ret; + if (!stream) { stream = camel_imap_folder_fetch_data (imap_folder, uid, "", FALSE, ex); @@ -1515,9 +1530,13 @@ get_message_simple (CamelImapFolder *imap_folder, const char *uid, } msg = camel_mime_message_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), - stream); + ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), + stream); camel_object_unref (CAMEL_OBJECT (stream)); + if (ret == -1) { + camel_object_unref (CAMEL_OBJECT (msg)); + return NULL; + } /* FIXME, this shouldn't be done this way. */ camel_medium_set_header (CAMEL_MEDIUM (msg), "X-Evolution-Source", @@ -1643,26 +1662,30 @@ static void add_message_from_data (CamelFolder *folder, GPtrArray *messages, int first, GData *data) { - int seq; CamelMimeMessage *msg; CamelStream *stream; CamelMessageInfo *mi; - + int seq; + seq = GPOINTER_TO_INT (g_datalist_get_data (&data, "SEQUENCE")); if (seq < first) return; stream = g_datalist_get_data (&data, "BODY_PART_STREAM"); if (!stream) return; - + if (seq - first >= messages->len) g_ptr_array_set_size (messages, seq - first + 1); - + msg = camel_mime_message_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream); + if (camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream) == -1) { + camel_object_unref (CAMEL_OBJECT (msg)); + return; + } + mi = camel_folder_summary_info_new_from_message (folder->summary, msg); camel_object_unref (CAMEL_OBJECT (msg)); - + messages->pdata[seq - first] = mi; } |