From 627b2aa69dba7bdd5c8356560eb67df830a06c94 Mon Sep 17 00:00:00 2001 From: helge Date: Fri, 27 Aug 2004 14:41:54 +0000 Subject: [PATCH] always use custom parser git-svn-id: http://svn.opengroupware.org/SOPE/trunk@67 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-mime/NGMime/ChangeLog | 6 ++ .../NGMimeRFC822DateHeaderFieldParser.m | 73 +------------------ sope-mime/Version | 2 +- 3 files changed, 9 insertions(+), 72 deletions(-) diff --git a/sope-mime/NGMime/ChangeLog b/sope-mime/NGMime/ChangeLog index 30c09920..a2825c7b 100644 --- a/sope-mime/NGMime/ChangeLog +++ b/sope-mime/NGMime/ChangeLog @@ -1,3 +1,9 @@ +2004-08-27 Helge Hess + + * NGMimeRFC822DateHeaderFieldParser.m: always use custom date parser + instead of the NSCalendarDate format parser (closes OGo bug #562) + (v4.3.174) + 2004-08-20 Helge Hess * now is a subproject of the sope-mime library just like NGImap4 and diff --git a/sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m b/sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m index 092213ef..75bfccb8 100644 --- a/sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m +++ b/sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m @@ -18,21 +18,15 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "NGMimeHeaderFieldParser.h" #include "NGMimeHeaderFields.h" #include "NGMimeUtilities.h" #include "common.h" -#define USE_CUSTOM_PARSER 1 - -// TODO: if it works out, remove the old parser! - @implementation NGMimeRFC822DateHeaderFieldParser static Class CalDateClass = Nil; -#if USE_CUSTOM_PARSER static NSTimeZone *gmt = nil; static NSTimeZone *gmt01 = nil; static NSTimeZone *gmt02 = nil; @@ -61,7 +55,6 @@ static NSTimeZone *gmtM12 = nil; static NSTimeZone *gmtM13 = nil; static NSTimeZone *gmtM14 = nil; static NSTimeZone *met = nil; -#endif + (int)version { return 2; @@ -72,7 +65,7 @@ static NSTimeZone *met = nil; didInit = YES; CalDateClass = [NSCalendarDate class]; -#if USE_CUSTOM_PARSER + /* timezones which were actually used in a maillist mailbox */ gmt = [[NSTimeZone timeZoneWithName:@"GMT"] retain]; met = [[NSTimeZone timeZoneWithName:@"MET"] retain]; @@ -102,7 +95,6 @@ static NSTimeZone *met = nil; gmtM12 = [[NSTimeZone timeZoneForSecondsFromGMT:-12 * (60 * 60)] retain]; gmtM13 = [[NSTimeZone timeZoneForSecondsFromGMT:-13 * (60 * 60)] retain]; gmtM14 = [[NSTimeZone timeZoneForSecondsFromGMT:-14 * (60 * 60)] retain]; -#endif } /* @@ -113,43 +105,6 @@ static NSTimeZone *met = nil; TODO: use an own parser for that. */ -#if !USE_CUSTOM_PARSER -static NSString *numDateFormats[] = { /* dateformats starting with a number */ - /* - day short-month year hour:minute:second timezoneoffset - eg: 01 Oct 1999 18:20:12 +0200 - */ - @"%d %b %Y %H:%M:%S %z", - - /* - day short-month year hour:minute:second timezonename - eg: 01 Oct 1999 18:20:12 EST - */ - @"%d %b %Y %H:%M:%S %Z", - - /* - day short-month year hour:minute:second (timezoneoffset) - eg: 30 Sep 1999 21:00:05 (+0200) - */ - @"%d %b %Y %H:%M:%S (%z)", - - /* - day short-month year hour:minute:second (timezonename) - eg: 30 Sep 1999 21:00:05 (MEST) - */ - @"%d %b %Y %H:%M:%S (%Z)", - - /* eg: '16 Jun 2002 10:28 GMT' */ - @"%d %b %Y %H:%M %Z", - - /* eg: '16 Jun 2002 10:28 +0000' */ - @"%d %b %Y %H:%M %z", - - /* terminate list */ - nil -}; -#endif - static int parseMonthOfYear(unsigned char *s, unsigned int len) { /* This one is *extremely* forgiving, it only checks what is @@ -320,14 +275,10 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { unsigned char buf[256]; unsigned char *bytes = buf, *pe; unsigned length = 0; -#if USE_CUSTOM_PARSER NSTimeZone *tz = nil; char dayOfMonth, monthOfYear, hour, minute, second; short year; BOOL flag; -#else - NSString *dateString = nil; -#endif if ((length = [_data cStringLength]) > 254) { [self logWithFormat: @@ -351,7 +302,7 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { return [CalDateClass date]; } -#if USE_CUSTOM_PARSER // TODO: should be a category on NSCalendarDate + // TODO: should be a category on NSCalendarDate // TODO: optimize much further! // first part: '16 Jun 2002' // snd part: '12:28[:11]' @@ -485,26 +436,6 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { [self logWithFormat:@"WARNING: failed to parse RFC822 date field: '%@'", _data]; return nil; - -#else - - dateString = - [[NSString alloc] initWithCString:bytes length:length]; - - /* check various date formats */ - { - int i; - - for (i = 0, date = nil; (date == nil) && (numDateFormats[i] != nil); i++) { - date = [CalDateClass dateWithString:dateString - calendarFormat:numDateFormats[i]]; - } - } - - [dateString release]; dateString = nil; - - return [date y2kDate]; -#endif } @end /* NGMimeRFC822DateHeaderFieldParser */ diff --git a/sope-mime/Version b/sope-mime/Version index 5c078793..6f3c7970 100644 --- a/sope-mime/Version +++ b/sope-mime/Version @@ -2,6 +2,6 @@ MAJOR_VERSION=4 MINOR_VERSION=3 -SUBMINOR_VERSION:=173 +SUBMINOR_VERSION:=174 # v4.2.149 requires libNGStreams v4.2.34 -- 2.39.5