aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-04-09 21:45:44 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-04-09 21:45:44 +0800
commitd89f072f8d45dd65ad62188a9e8b5f903ea2faf5 (patch)
tree76247ba6842f7b4c690244038142f7dc22dc0a0c
parentb2c4de41b127c433577cc886b54ad0caa9a9787d (diff)
downloadgsoc2013-evolution-d89f072f8d45dd65ad62188a9e8b5f903ea2faf5.tar
gsoc2013-evolution-d89f072f8d45dd65ad62188a9e8b5f903ea2faf5.tar.gz
gsoc2013-evolution-d89f072f8d45dd65ad62188a9e8b5f903ea2faf5.tar.bz2
gsoc2013-evolution-d89f072f8d45dd65ad62188a9e8b5f903ea2faf5.tar.lz
gsoc2013-evolution-d89f072f8d45dd65ad62188a9e8b5f903ea2faf5.tar.xz
gsoc2013-evolution-d89f072f8d45dd65ad62188a9e8b5f903ea2faf5.tar.zst
gsoc2013-evolution-d89f072f8d45dd65ad62188a9e8b5f903ea2faf5.zip
If we get multiple Content-Type header values, change subsequent headers
2002-04-09 Not Zed <NotZed@Ximian.com> * camel-mime-part.c (construct_from_parser): If we get multiple Content-Type header values, change subsequent headers to X-Invalid-Content-Type so it doesn't wreck processing. This fixes the reported case in #18929, but i dont know if it fixes the original posters problems. 2002-04-08 Not Zed <NotZed@Ximian.com> * camel-vtrash-folder.c (vtrash_move_messages_to): If we find we're moving from the vtrash to another folder, we need to convert the uid from a vfolder uid to the source uid (+8). Fix for #20886. Also changed to batch multiple moves to different folders so they are done as efficiently as possible rather than one at a time. * camel-mime-utils.c (base64_decode_step): If we only get passed '=', we back track only if we actually output any data. Fix for #21716. (quoted_decode): Pass out size_t instead of int, and use 0 instead of -1 for error since its not signed. This will fix similar bug to above in different circumstances since the result is taken as unsigned. This is only an internal func. (quoted_encode): Return size_t just for consistency. * camel-block-file.c (block_file_validate_root): Comment out the debug and move it into a warning when the validation fails. svn path=/trunk/; revision=16394
-rw-r--r--camel/ChangeLog29
-rw-r--r--camel/camel-block-file.c28
-rw-r--r--camel/camel-mime-parser.c2
-rw-r--r--camel/camel-mime-part.c9
-rw-r--r--camel/camel-mime-utils.c8
-rw-r--r--camel/camel-vtrash-folder.c57
6 files changed, 104 insertions, 29 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index e6fc009227..863e33bb14 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,32 @@
+2002-04-09 Not Zed <NotZed@Ximian.com>
+
+ * camel-mime-part.c (construct_from_parser): If we get multiple
+ Content-Type header values, change subsequent headers to
+ X-Invalid-Content-Type so it doesn't wreck processing. This fixes
+ the reported case in #18929, but i dont know if it fixes the
+ original posters problems.
+
+2002-04-08 Not Zed <NotZed@Ximian.com>
+
+ * camel-vtrash-folder.c (vtrash_move_messages_to): If we find
+ we're moving from the vtrash to another folder, we need to convert
+ the uid from a vfolder uid to the source uid (+8). Fix for
+ #20886. Also changed to batch multiple moves to different folders
+ so they are done as efficiently as possible rather than one at a
+ time.
+
+ * camel-mime-utils.c (base64_decode_step): If we only get passed
+ '=', we back track only if we actually output any data. Fix for
+ #21716.
+ (quoted_decode): Pass out size_t instead of int, and use 0 instead
+ of -1 for error since its not signed. This will fix similar bug
+ to above in different circumstances since the result is taken as
+ unsigned. This is only an internal func.
+ (quoted_encode): Return size_t just for consistency.
+
+ * camel-block-file.c (block_file_validate_root): Comment out the
+ debug and move it into a warning when the validation fails.
+
2002-04-08 Jeffrey Stedfast <fejj@ximian.com>
* camel-mime-utils.c (uuencode_close): Don't count our filler when
diff --git a/camel/camel-block-file.c b/camel/camel-block-file.c
index 6b889f9da1..34e62a7c8a 100644
--- a/camel/camel-block-file.c
+++ b/camel/camel-block-file.c
@@ -98,22 +98,15 @@ block_file_validate_root(CamelBlockFile *bs)
fstat(bs->fd, &st);
- (printf("Validate root: '%s'\n", bs->path));
- (printf("version: %.8s (%.8s)\n", bs->root->version, bs->version));
- (printf("block size: %d (%d)%s\n", br->block_size, bs->block_size,
+ d(printf("Validate root: '%s'\n", bs->path));
+ d(printf("version: %.8s (%.8s)\n", bs->root->version, bs->version));
+ d(printf("block size: %d (%d)%s\n", br->block_size, bs->block_size,
br->block_size != bs->block_size ? " BAD":" OK"));
- (printf("free: %ld (%d add size < %ld)%s\n", (long)br->free, br->free / bs->block_size * bs->block_size, (long)st.st_size,
+ d(printf("free: %ld (%d add size < %ld)%s\n", (long)br->free, br->free / bs->block_size * bs->block_size, (long)st.st_size,
(br->free > st.st_size) || (br->free % bs->block_size) != 0 ? " BAD":" OK"));
- (printf("last: %ld (%d and size: %ld)%s\n", (long)br->last, br->last / bs->block_size * bs->block_size, (long)st.st_size,
+ d(printf("last: %ld (%d and size: %ld)%s\n", (long)br->last, br->last / bs->block_size * bs->block_size, (long)st.st_size,
(br->last != st.st_size) || ((br->last % bs->block_size) != 0) ? " BAD": " OK"));
- (printf("flags: %s\n", (br->flags & CAMEL_BLOCK_FILE_SYNC)?"SYNC":"unSYNC"));
-
- printf("last = %ld, size = %ld\n", (unsigned long)br->last, (unsigned long)st.st_size);
-
- if (br->last != st.st_size)
- printf("last != size!\n");
- else
- printf("last == size?\n");
+ d(printf("flags: %s\n", (br->flags & CAMEL_BLOCK_FILE_SYNC)?"SYNC":"unSYNC"));
if (br->last == 0
|| memcmp(bs->root->version, bs->version, 8) != 0
@@ -124,6 +117,15 @@ block_file_validate_root(CamelBlockFile *bs)
|| st.st_size != br->last
|| br->free > st.st_size
|| (br->flags & CAMEL_BLOCK_FILE_SYNC) == 0) {
+ g_warning("Invalid root: '%s'\n", bs->path);
+ g_warning("version: %.8s (%.8s)\n", bs->root->version, bs->version);
+ g_warning("block size: %d (%d)%s\n", br->block_size, bs->block_size,
+ br->block_size != bs->block_size ? " BAD":" OK");
+ g_warning("free: %ld (%d add size < %ld)%s\n", (long)br->free, br->free / bs->block_size * bs->block_size, (long)st.st_size,
+ (br->free > st.st_size) || (br->free % bs->block_size) != 0 ? " BAD":" OK");
+ g_warning("last: %ld (%d and size: %ld)%s\n", (long)br->last, br->last / bs->block_size * bs->block_size, (long)st.st_size,
+ (br->last != st.st_size) || ((br->last % bs->block_size) != 0) ? " BAD": " OK");
+ g_warning("flags: %s\n", (br->flags & CAMEL_BLOCK_FILE_SYNC)?"SYNC":"unSYNC");
return -1;
}
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index dd9c979d63..f57583135d 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -47,7 +47,7 @@
#define r(x)
#define h(x)
-#define c(x)
+#define c(x)
#define d(x)
/*#define PURIFY*/
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 614ba186b8..e64fc94927 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -249,7 +249,7 @@ process_header(CamelMedium *medium, const char *header_name, const char *header_
g_free (mime_part->content_location);
mime_part->content_location = header_location_decode (header_value);
break;
- case HEADER_CONTENT_TYPE:
+ case HEADER_CONTENT_TYPE:
if (mime_part->content_type)
header_content_type_unref (mime_part->content_type);
mime_part->content_type = header_content_type_decode (header_value);
@@ -785,9 +785,14 @@ construct_from_parser(CamelMimePart *dw, CamelMimeParser *mp)
process_header((CamelMedium *)dw, "content-type", content);
while (headers) {
- camel_medium_add_header((CamelMedium *)dw, headers->name, headers->value);
+ if (strcasecmp(headers->name, "content-type") == 0
+ && headers->value != content)
+ camel_medium_add_header((CamelMedium *)dw, "X-Invalid-Content-Type", headers->value);
+ else
+ camel_medium_add_header((CamelMedium *)dw, headers->name, headers->value);
headers = headers->next;
}
+
camel_mime_part_construct_content_from_parser(dw, mp);
break;
default:
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 328a6dfce3..148eea9a80 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -375,7 +375,7 @@ base64_decode_step(unsigned char *in, size_t len, unsigned char *out, int *state
while (inptr>in && i) {
inptr--;
if (camel_mime_base64_rank[*inptr] != 0xff) {
- if (*inptr == '=')
+ if (*inptr == '=' && outptr>out)
outptr--;
i--;
}
@@ -869,7 +869,7 @@ quoted_decode_step(unsigned char *in, size_t len, unsigned char *out, int *saves
this is for the "Q" encoding of international words,
which is slightly different than plain quoted-printable (mainly by allowing 0x20 <> _)
*/
-static int
+static size_t
quoted_decode(const unsigned char *in, size_t len, unsigned char *out)
{
register const unsigned char *inptr;
@@ -910,13 +910,13 @@ quoted_decode(const unsigned char *in, size_t len, unsigned char *out)
if (ret==0) {
return outptr-out;
}
- return -1;
+ return 0;
}
/* rfc2047 version of quoted-printable */
/* safemask is the mask to apply to the camel_mime_special_table to determine what
characters can safely be included without encoding */
-static int
+static size_t
quoted_encode (const unsigned char *in, size_t len, unsigned char *out, unsigned short safemask)
{
register const unsigned char *inptr, *inend;
diff --git a/camel/camel-vtrash-folder.c b/camel/camel-vtrash-folder.c
index 06764af674..cb390eacda 100644
--- a/camel/camel-vtrash-folder.c
+++ b/camel/camel-vtrash-folder.c
@@ -117,12 +117,34 @@ vtrash_copy_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest
_("You cannot copy messages from this trash folder."));
}
+struct _move_data {
+ CamelFolder *folder;
+ CamelFolder *dest;
+ GPtrArray *uids;
+};
+
+static void
+move_messages(CamelFolder *folder, struct _move_data *md, CamelException *ex)
+{
+ int i;
+
+ camel_folder_move_messages_to(md->folder, md->uids, md->dest, ex);
+ for (i=0;i<md->uids->len;i++)
+ g_free(md->uids->pdata[i]);
+ g_ptr_array_free(md->uids, TRUE);
+ camel_object_unref((CamelObject *)md->folder);
+ g_free(md);
+}
+
static void
vtrash_move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex)
{
CamelVeeMessageInfo *mi;
int i;
-
+ GHashTable *batch = NULL;
+ const char *tuid;
+ struct _move_data *md;
+
for (i = 0; i < uids->len; i++) {
mi = (CamelVeeMessageInfo *)camel_folder_get_message_info (source, uids->pdata[i]);
if (mi == NULL) {
@@ -135,15 +157,32 @@ vtrash_move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest
camel_folder_set_message_flags (source, uids->pdata[i], CAMEL_MESSAGE_DELETED, 0);
} else {
/* This means that the user is trying to move the message
- from the vTrash to a folder other than the original. */
- GPtrArray *tuids;
-
- tuids = g_ptr_array_new ();
- g_ptr_array_add (tuids, uids->pdata[i]);
- camel_folder_move_messages_to (mi->folder, tuids, dest, ex);
- g_ptr_array_free (tuids, TRUE);
+ from the vTrash to a folder other than the original.
+ We batch them up as much as we can */
+
+ if (batch == NULL)
+ batch = g_hash_table_new(NULL, NULL);
+ md = g_hash_table_lookup(batch, mi->folder);
+ if (md == NULL) {
+ md = g_malloc0(sizeof(*md));
+ md->folder = mi->folder;
+ camel_object_ref((CamelObject *)md->folder);
+ md->uids = g_ptr_array_new();
+ md->dest = dest;
+ g_hash_table_insert(batch, mi->folder, md);
+ }
+
+ tuid = uids->pdata[i];
+ if (strlen(tuid)>8)
+ tuid += 8;
+ printf("moving message uid '%s'\n", tuid);
+ g_ptr_array_add(md->uids, g_strdup(tuid));
}
-
camel_folder_free_message_info (source, (CamelMessageInfo *)mi);
}
+
+ if (batch) {
+ g_hash_table_foreach(batch, (GHFunc)move_messages, ex);
+ g_hash_table_destroy(batch);
+ }
}