From 9cda34a65f3b92dd92f41e44e6fb8acdac121f64 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 2 Oct 2019 10:45:37 -0400 Subject: [PATCH] Fix handling of SENT-BY addresses Fixes #4583 --- NEWS | 1 + .../Appointments/SOGoAppointmentObject.m | 22 ++----------------- SoObjects/Appointments/iCalPerson+SOGo.m | 11 ++++++---- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/NEWS b/NEWS index 5cf1ae392..4921956a0 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 12e0f3730..97a286405 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -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]; } diff --git a/SoObjects/Appointments/iCalPerson+SOGo.m b/SoObjects/Appointments/iCalPerson+SOGo.m index 9f2fbde05..25551ddee 100644 --- a/SoObjects/Appointments/iCalPerson+SOGo.m +++ b/SoObjects/Appointments/iCalPerson+SOGo.m @@ -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 @"";