From 518c7e716f08ae75e43ac4ed54e20196dfe6db92 Mon Sep 17 00:00:00 2001 From: znek Date: Tue, 19 Oct 2004 17:13:06 +0000 Subject: [PATCH] improved robustness git-svn-id: http://svn.opengroupware.org/SOPE/trunk@279 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-ical/versitSaxDriver/ChangeLog | 10 ++++++++++ sope-ical/versitSaxDriver/README | 9 +++++++++ sope-ical/versitSaxDriver/VSSaxDriver.m | 24 ++++++++++++++++++++++-- sope-ical/versitSaxDriver/Version | 2 +- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/sope-ical/versitSaxDriver/ChangeLog b/sope-ical/versitSaxDriver/ChangeLog index 631b3cc8..54c70c66 100644 --- a/sope-ical/versitSaxDriver/ChangeLog +++ b/sope-ical/versitSaxDriver/ChangeLog @@ -1,3 +1,13 @@ +2004-10-19 Marcus Mueller + + * v4.3.9 + + * VSSaxDriver.m: improved robustness in respect to illegal content + lines - the parser shouldn't crash anymore. Also, changed the + "OGoDebugVersitSaxDriver" default to "VSSaxDriverDebugEnabled". + + * README: documented the default + 2004-10-18 Marcus Mueller * v4.3.8 diff --git a/sope-ical/versitSaxDriver/README b/sope-ical/versitSaxDriver/README index 67fc2bfa..4fd5253f 100644 --- a/sope-ical/versitSaxDriver/README +++ b/sope-ical/versitSaxDriver/README @@ -33,6 +33,15 @@ ToDo - make the driver fully xCal compliant +Defaults +======== + +Name Type Description +------------------------------------------------------------------------------ +VSSaxDriverDebugEnabled BOOL YES -> log some debug information + via NSLog + + Examples ======== diff --git a/sope-ical/versitSaxDriver/VSSaxDriver.m b/sope-ical/versitSaxDriver/VSSaxDriver.m index a0399b22..230594d4 100644 --- a/sope-ical/versitSaxDriver/VSSaxDriver.m +++ b/sope-ical/versitSaxDriver/VSSaxDriver.m @@ -48,7 +48,7 @@ static VSStringFormatter *stringFormatter = nil; didInit = YES; ud = [NSUserDefaults standardUserDefaults]; - debugOn = [ud boolForKey:@"OGoDebugVersitSaxDriver"]; + debugOn = [ud boolForKey:@"VSSaxDriverDebugEnabled"]; dotCharSet = [[NSCharacterSet characterSetWithCharactersInString:@"."] retain]; @@ -416,12 +416,22 @@ static VSStringFormatter *stringFormatter = nil; unsigned length; length = [_line length]; - tagAttributes = [[NSMutableArray alloc] init]; todoRange = NSMakeRange(0, length); r = [_line rangeOfCharacterFromSet:colonAndSemicolonCharSet options:0 range:todoRange]; + if(r.length == 0) { + if(debugOn) { + NSLog(@"%s got an improper content line! ->\n%@", + __PRETTY_FUNCTION__, + _line); + } + return; + } + tagName = [[_line substringToIndex:r.location] uppercaseString]; + tagAttributes = [[NSMutableArray alloc] init]; + if([_line characterAtIndex:r.location] != ':') { BOOL isAtEnd = NO, isInDquote = NO; unsigned start = NSMaxRange(r); @@ -434,6 +444,16 @@ static VSStringFormatter *stringFormatter = nil; r = [_line rangeOfCharacterFromSet:colonSemicolonAndDquoteCharSet options:0 range:todoRange]; + /* is line well-formed ? */ + if(r.length == 0 || r.location == 0) { + if(debugOn) { + NSLog(@"%s got an improper content line! ->\n%@", + __PRETTY_FUNCTION__, + _line); + } + [tagAttributes release]; + return; + } /* first check if delimiter candidate is escaped */ if([_line characterAtIndex:(r.location - 1)] != '\\') { unichar delimiter; diff --git a/sope-ical/versitSaxDriver/Version b/sope-ical/versitSaxDriver/Version index edfa2d83..b191a15e 100644 --- a/sope-ical/versitSaxDriver/Version +++ b/sope-ical/versitSaxDriver/Version @@ -1,3 +1,3 @@ # Version file -SUBMINOR_VERSION:=8 +SUBMINOR_VERSION:=9 -- 2.39.5