mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-04 12:58:50 +00:00
fix(calendar): try to repair VCALENDAR when parsing versit string
It seems that Exchange 2010 and 2016 sometimes produce calendar invitation emails with text/calendar multipart parts in the email that have "END:VCALENDAR" at the end of the calendar data missing.
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#import "iCalEvent.h"
|
||||
#import "iCalToDo.h"
|
||||
#import "iCalJournal.h"
|
||||
@@ -39,6 +41,30 @@
|
||||
|
||||
@implementation iCalCalendar
|
||||
|
||||
+ (NSArray *) parseFromSource: (id) source
|
||||
{
|
||||
NSArray *result;
|
||||
NSMutableString *content;
|
||||
|
||||
result = [super parseFromSource: source];
|
||||
|
||||
// If parsing doesn't return any card, check if the opening tag is present but the ending tag
|
||||
// missing. Add the ending tag and parse the source again in this case.
|
||||
if ([result count] == 0 &&
|
||||
[source length] &&
|
||||
[source hasPrefix: @"BEGIN:VCALENDAR"] &&
|
||||
!([source hasSuffix: @"END:VCALENDAR\r\n"] || [source hasSuffix: @"END:VCALENDAR"]))
|
||||
{
|
||||
content = [NSMutableString stringWithString: source];
|
||||
[content appendString: @"END:VCALENDAR"];
|
||||
result = [super parseFromSource: content];
|
||||
if ([result count] > 0)
|
||||
[self logWithFormat: @"Successfully repaired VCALENDAR by adding ending tag"];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* class mapping */
|
||||
- (Class) classForTag: (NSString *) classTag
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user