dovecot-1.0: Nowadays the SORT draft specifies that if Date: hea...

dovecot at dovecot.org dovecot at dovecot.org
Tue Oct 16 16:55:24 EEST 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/c65c5aeaf115
changeset: 5423:c65c5aeaf115
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Oct 16 16:55:16 2007 +0300
description:
Nowadays the SORT draft specifies that if Date: header is missing or broken,
SORT should fallback to using INTERNALDATE.

diffstat:

1 file changed, 16 insertions(+), 3 deletions(-)
src/imap/imap-sort.c |   19 ++++++++++++++++---

diffs (50 lines):

diff -r 880d21a2a629 -r c65c5aeaf115 src/imap/imap-sort.c
--- a/src/imap/imap-sort.c	Sat Oct 06 03:05:36 2007 +0300
+++ b/src/imap/imap-sort.c	Tue Oct 16 16:55:16 2007 +0300
@@ -301,6 +301,19 @@ static const char *get_first_mailbox(str
 	return addr != NULL ? addr->mailbox : NULL;
 }
 
+static time_t mail_sort_get_date(struct mail *mail)
+{
+	time_t t;
+
+	t = mail_get_date(mail, NULL);
+	if (t == 0) {
+		/* missing or broken Date: header,
+		   fallback to INTERNALDATE */
+		t = mail_get_received_date(mail);
+	}
+	return t;
+}
+
 static void mail_sort_check_flush(struct sort_context *ctx, struct mail *mail)
 {
 	const char *str;
@@ -329,7 +342,7 @@ static void mail_sort_check_flush(struct
 	}
 
 	if (ctx->common_mask & MAIL_SORT_DATE) {
-		t = mail_get_date(mail, NULL);
+		t = mail_sort_get_date(mail);
 		if (t != ctx->last_date) {
 			ctx->last_date = t;
 			changed = TRUE;
@@ -417,7 +430,7 @@ static void mail_sort_input(struct sort_
 		if (ctx->common_mask & MAIL_SORT_DATE)
 			t = ctx->last_date;
 		else
-			t = mail_get_date(mail, NULL);
+			t = mail_sort_get_date(mail);
 		memcpy(buf + pos, &t, sizeof(t)); pos += sizeof(t);
 	}
 
@@ -531,7 +544,7 @@ static time_t get_time(enum mail_sort_ty
 		case MAIL_SORT_ARRIVAL:
 			return mail_get_received_date(mail);
 		case MAIL_SORT_DATE:
-			t = mail_get_date(mail, NULL);
+			t = mail_sort_get_date(mail);
 			if (t == (time_t)-1)
 				t = 0;
 			return t;


More information about the dovecot-cvs mailing list