[evolution-patches] Broken date detection fix



Hi,

I've discovered three mails on my home account which had broken dates
not detected correctly as broken by (camel_)header_decode_date, so they
would be decoded by broken-date-parser.

The broken date format where :
29-Sep-2003 06:58:17 (sent by French tax payment service)
and
Mon, Sep 15 2003 13:34:27 -0700 (this one was sent by Microsoft .Net
Passport service :))

The following patches (for 1.4 branch and HEAD) fixes header_decode_date
so it correctly detect when the standard parsing failed so it should
switch to broken date parser.

Can I commit to CVS ?
-- 
Frederic Crozat <fcrozat mandrakesoft com>
Mandrakesoft
? .camel-mime-utils.c.swp
? evolution-head-brokendate.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1900
diff -u -r1.1900 ChangeLog
--- ChangeLog	23 Oct 2003 19:57:56 -0000	1.1900
+++ ChangeLog	27 Oct 2003 18:11:02 -0000
@@ -1,3 +1,8 @@
+2003-10-27  Frederic Crozat  <fcrozat mandrakesoft com>
+
+	* camel-mime-utils.c: (camel_header_decode_date):
+	better detection of broken date to give to broken_date_parser.
+
 2003-10-23  Jeffrey Stedfast  <fejj ximian com>
 
 	* *.c: Removed unneeded CAMEL_OBJECT() casts.
Index: camel-mime-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-utils.c,v
retrieving revision 1.195
diff -u -r1.195 camel-mime-utils.c
--- camel-mime-utils.c	9 Oct 2003 16:46:30 -0000	1.195
+++ camel-mime-utils.c	27 Oct 2003 18:11:02 -0000
@@ -3489,6 +3489,7 @@
 {
 	const char *inptr = in;
 	char *monthname;
+	gboolean foundmonth;
 	int year, offset = 0;
 	struct tm tm;
 	int i;
@@ -3526,16 +3527,30 @@
 		}
 	}
 	tm.tm_mday = camel_header_decode_int(&inptr);
+#ifndef CLEAN_DATE
+	if (tm.tm_mday == 0) {
+		return parse_broken_date (in, saveoffset);
+	}
+#endif /* ! CLEAN_DATE */
+
 	monthname = decode_token(&inptr);
+	foundmonth = FALSE;
 	if (monthname) {
 		for (i=0;i<sizeof(tz_months)/sizeof(tz_months[0]);i++) {
 			if (!strcasecmp(tz_months[i], monthname)) {
 				tm.tm_mon = i;
+				foundmonth = TRUE;
 				break;
 			}
 		}
 		g_free(monthname);
 	}
+#ifndef CLEAN_DATE
+	if (!foundmonth) {
+		return parse_broken_date (in, saveoffset);
+	}
+#endif /* ! CLEAN_DATE */
+
 	year = camel_header_decode_int(&inptr);
 	if (year < 69) {
 		tm.tm_year = 100 + year;
? .camel-mime-utils.c.swp
? broken-date-parser
? evolution-1.4.5-brokendate.patch
? providers/imapp/Makefile
? providers/imapp/Makefile.in
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1836.2.17
diff -u -r1.1836.2.17 ChangeLog
--- ChangeLog	17 Oct 2003 00:52:53 -0000	1.1836.2.17
+++ ChangeLog	27 Oct 2003 18:02:57 -0000
@@ -1,3 +1,8 @@
+2003-10-27  Frederic Crozat  <fcrozat mandrakesoft com>
+
+	* camel-mime-utils.c: (header_decode_date):
+	better detection of broken date to give to broken_date_parser.
+
 2003-10-08  Not Zed  <NotZed Ximian com>
 
 	** See Bug #45504
Index: camel-mime-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-utils.c,v
retrieving revision 1.183.4.5
diff -u -r1.183.4.5 camel-mime-utils.c
--- camel-mime-utils.c	9 Oct 2003 16:41:21 -0000	1.183.4.5
+++ camel-mime-utils.c	27 Oct 2003 18:02:58 -0000
@@ -3457,6 +3457,7 @@
 {
 	const char *inptr = in;
 	char *monthname;
+	gboolean foundmonth;
 	int year, offset = 0;
 	struct tm tm;
 	int i;
@@ -3494,16 +3495,28 @@
 		}
 	}
 	tm.tm_mday = header_decode_int(&inptr);
+#ifndef CLEAN_DATE
+	if (tm.tm_mday == 0) {
+		return parse_broken_date (in, saveoffset);
+	}
+#endif /* ! CLEAN_DATE */
 	monthname = decode_token(&inptr);
+	foundmonth = FALSE;
 	if (monthname) {
 		for (i=0;i<sizeof(tz_months)/sizeof(tz_months[0]);i++) {
 			if (!strcasecmp(tz_months[i], monthname)) {
 				tm.tm_mon = i;
+				foundmonth = TRUE;
 				break;
 			}
 		}
 		g_free(monthname);
 	}
+#ifndef CLEAN_DATE
+	if (!foundmonth) {
+		return parse_broken_date (in, saveoffset);
+	}
+#endif /* ! CLEAN_DATE */
 	year = header_decode_int(&inptr);
 	if (year < 69) {
 		tm.tm_year = 100 + year;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]