Fix handling of SENT-BY addresses

Fixes #4583
pull/259/head
Francis Lachapelle 2019-10-02 10:45:37 -04:00
parent 01bda0783c
commit 9cda34a65f
3 changed files with 10 additions and 24 deletions

1
NEWS
View File

@ -30,6 +30,7 @@ Bug fixes
- [core] avoid exceptions for RRULE with no DTSTART
- [core] make sure we handle events occurring after RRULE's UNTIL date
- [core] avoid changing RRULE's UNTIL date for no reason
- [core] fixed handling of SENT-BY addresses (#4583)
- [eas] improve FolderSync operation (#4672)
- [eas] avoid incorrect truncation leading to exception (#4806)

View File

@ -2123,21 +2123,6 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
return [super DELETEAction: _ctx];
}
//
// Let's check if our CalDAV client has sent us a broken SENT-BY. When Lightning is identity-aware,
// it'll stupidly send something like this:
// ORGANIZER;RSVP=TRUE;CN=John Doe;PARTSTAT=ACCEPTED;ROLE=CHAIR;SENT-BY="mail
// to:mailto:sogo3@example.com":mailto:sogo1@example.com
//
- (void) _fixupSentByForPerson: (iCalPerson *) person
{
NSString *sentBy;
sentBy = [person sentBy];
if ([sentBy hasPrefix: @"mailto:"])
[person setSentBy: [sentBy substringFromIndex: 7]];
}
//
// This method is meant to be the common point of any save operation from web
// and DAV requests, as well as from code making use of SOGo as a library
@ -2226,8 +2211,6 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
attendees = [event attendeesWithoutUser: ownerUser];
if ([attendees count])
{
[self _fixupSentByForPerson: [event organizer]];
if ((ex = [self _handleAddedUsers: attendees fromEvent: event force: YES]))
return ex;
else
@ -2405,8 +2388,6 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
// We check ACLs of the 'organizer' - in case someone forges the SENT-BY
NSString *uid;
[self _fixupSentByForPerson: [newEvent organizer]];
uid = [[oldEvent organizer] uidInContext: context];
if (uid && [[[context activeUser] login] caseInsensitiveCompare: uid] != NSOrderedSame)
@ -2486,7 +2467,8 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
if ([delegateEmail length])
{
delegateEmail = [delegateEmail substringFromIndex: 7];
if ([[delegateEmail lowercaseString] hasPrefix: @"mailto:"])
delegateEmail = [delegateEmail substringFromIndex: 7];
if ([delegateEmail length])
delegate = [newEvent findAttendeeWithEmail: delegateEmail];
}

View File

@ -131,7 +131,7 @@ static SOGoUserManager *um = nil;
mail = [self value: 0 ofAttribute: @"SENT-BY"];
return ([mail length] > 7);
return [mail length];
}
- (NSString *) sentBy
@ -140,12 +140,15 @@ static SOGoUserManager *um = nil;
mail = [self value: 0 ofAttribute: @"SENT-BY"];
if ([mail length] > 7)
if ([mail length])
{
if ([mail characterAtIndex: 0] == '"' && [mail hasSuffix: @"\""])
mail = [mail substringWithRange: NSMakeRange(1, [mail length]-2)];
return [mail substringFromIndex: 7];
if ([[mail lowercaseString] hasPrefix: @"mailto:"])
mail = [mail substringFromIndex: 7];
return mail;
}
return @"";