From: znek Date: Mon, 18 Oct 2004 13:44:12 +0000 (+0000) Subject: added robustness X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=214b3d3cdd1c590061698cd2258dbbc79077de54;p=sope added robustness git-svn-id: http://svn.opengroupware.org/SOPE/trunk@273 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-ical/versitSaxDriver/ChangeLog b/sope-ical/versitSaxDriver/ChangeLog index 7d3cba96..631b3cc8 100644 --- a/sope-ical/versitSaxDriver/ChangeLog +++ b/sope-ical/versitSaxDriver/ChangeLog @@ -1,7 +1,17 @@ 2004-10-18 Marcus Mueller + * v4.3.8 + + * VSSaxDriver.m: added support in _parseString: for Unix style + terminated content lines. Such content lines clearly violate the + RFC but such ical files happen to appear in the wildlife. + + * README: updated + + * v4.3.7 + * Version: removed major and minor. This effectively bumps the version - to v4.3.7 which is in sync with the rest of sope-ical (v4.3.7) + to v4.3.7 which is in sync with the rest of sope-ical. 2004-10-17 Helge Hess diff --git a/sope-ical/versitSaxDriver/README b/sope-ical/versitSaxDriver/README index 474d5672..67fc2bfa 100644 --- a/sope-ical/versitSaxDriver/README +++ b/sope-ical/versitSaxDriver/README @@ -19,12 +19,16 @@ tested as of now) iCalSaxDriver. However, the iCalSaxDriver depends on the abandoned and hardly maintainable libical, which itself is an additional dependency to the OGo project and thus a welcome candidate for replacement. +The VSSaxDriver attempts to follow RFC2445 closely, however the parser is +written to be robust when it comes to parsing real life content. Currently, +unescaping is done for more characters then it MUST according to RFC2445, but +this is probably not a bad idea - wrongly escaped characters will still be +parsed according to the original intent. Also, the VSSaxDriver supports Unix +style terminated lines/folding. ToDo ==== -- REWRITE _parseLine:! It doesn't properly deal with escaped characters - as it SHOULD, thus properly corrupting content - improve error handling (SaxExceptions !) - make the driver fully xCal compliant diff --git a/sope-ical/versitSaxDriver/VSSaxDriver.m b/sope-ical/versitSaxDriver/VSSaxDriver.m index 252cb75d..a0399b22 100644 --- a/sope-ical/versitSaxDriver/VSSaxDriver.m +++ b/sope-ical/versitSaxDriver/VSSaxDriver.m @@ -552,6 +552,34 @@ static VSStringFormatter *stringFormatter = nil; } } } + else if(c == '\n') { /* broken, non-standard */ + BOOL isAtEndOfLine = YES; + /* test for folding first */ + if(((length - 1) - pos) >= 1) { + unichar ws = [_rawString characterAtIndex:pos + 1]; + isAtEndOfLine = [whitespaceCharSet characterIsMember:ws] ? NO + : YES; + if(!isAtEndOfLine) { + /* assemble part of line up to pos */ + if(r.length > 0) { + [line appendString:[_rawString substringWithRange:r]]; + } + /* unfold */ + pos += 1; + r = NSMakeRange(pos + 1, 0); /* begin new range */ + } + } + if(isAtEndOfLine) { + /* assemble part of line up to pos */ + if(r.length > 0) { + [line appendString:[_rawString substringWithRange:r]]; + } + [self _parseLine:line]; + /* reset line */ + [line deleteCharactersInRange:NSMakeRange(0, [line length])]; + r = NSMakeRange(pos + 1, 0); /* begin new range */ + } + } else { r.length += 1; }