Skip to content

Commit

Permalink
(fix) improved previous commit for attributes stripping and UID gener…
Browse files Browse the repository at this point in the history
…ation (fixes #3695 and #3696)
  • Loading branch information
extrafu committed May 27, 2016
1 parent 6047059 commit 875a4ac
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 22 deletions.
47 changes: 27 additions & 20 deletions SoObjects/Appointments/SOGoCalendarComponent.m
Expand Up @@ -41,12 +41,14 @@
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSObject+DAV.h>
#import <SOGo/NSObject+Utilities.h>
#import <SOGo/NSString+Crypto.h>
#import <SOGo/NSString+Utilities.h>
#import <SOGo/SOGoBuild.h>
#import <SOGo/SOGoMailer.h>
#import <SOGo/SOGoGroup.h>
#import <SOGo/SOGoPermissions.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserSettings.h>
#import <SOGo/SOGoSystemDefaults.h>
#import <SOGo/SOGoUserManager.h>
#import <SOGo/SOGoWebDAVAclManager.h>
Expand Down Expand Up @@ -202,14 +204,21 @@ - (void) setComponentTag: (NSString *) theTag

- (void) _filterComponent: (iCalEntityObject *) component
{
NSString *type, *summary, *tag;
NSArray *children;
NSString *type, *summary, *tag, *uid;
SOGoUserSettings *settings;
SOGoUser *calendarOwner;
NSEnumerator *children;
CardElement *element;
NSArray *tags;

int classification, i;
int classification;

type = @"vtodo";
classification = 0;

calendarOwner = [SOGoUser userWithLogin: [self ownerInContext: context]];
settings = [calendarOwner userSettings];

if ([component isKindOfClass: [iCalEvent class]])
type = @"vevent";

Expand All @@ -221,25 +230,23 @@ - (void) _filterComponent: (iCalEntityObject *) component
summary = [self labelForKey: [NSString stringWithFormat: @"%@_class%d",
type, classification]
inContext: context];
[component setSummary: summary];
[component setComment: @""];
[component setUserComment: @""];
[component setLocation: @""];
[component setCategories: [NSArray array]];
[component setUrl: @""];
[component setOrganizer: nil];
[component removeAllAttendees];
[component removeAllAlarms];

// We strip all X- tags
children = [component children];

for (i = 0; i < [children count]; i++)

tags = [NSArray arrayWithObjects: @"DTSTAMP", @"DTSTART", @"DTEND", @"DUE", @"EXDATE", @"EXRULE", @"RRULE", nil];
uid = [[component uid] asCryptedPassUsingScheme: @"ssha256"
withSalt: [[settings userSalt] dataUsingEncoding: NSASCIIStringEncoding]
andEncoding: encHex];

children = [[[[component children] copy] autorelease] objectEnumerator];

while ((element = [children nextObject]))
{
tag = [[children objectAtIndex: i] tag];
if ([[tag uppercaseString] hasPrefix: @"X-"])
[component removeChild: [children objectAtIndex: i]];
tag = [element tag];
if (![tags containsObject: [tag uppercaseString]])
[component removeChild: element];
}

[component setSummary: summary];
[component setUid: uid];
}

- (NSString *) secureContentAsString
Expand Down
3 changes: 2 additions & 1 deletion SoObjects/SOGo/SOGoUserSettings.h
@@ -1,6 +1,6 @@
/* SOGoUserSettings.h - this file is part of SOGo
*
* Copyright (C) 2009-2014 Inverse inc.
* Copyright (C) 2009-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -33,6 +33,7 @@

- (NSArray *) subscribedCalendars;
- (NSArray *) subscribedAddressBooks;
- (NSString *) userSalt;

@end

Expand Down
28 changes: 27 additions & 1 deletion SoObjects/SOGo/SOGoUserSettings.m
@@ -1,6 +1,6 @@
/* SOGoUserSettings.m - this file is part of SOGo
*
* Copyright (C) 2009-2014 Inverse inc.
* Copyright (C) 2009-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -19,9 +19,11 @@
*/

#import <Foundation/NSDictionary.h>
#import <Foundation/NSProcessInfo.h>
#import <Foundation/NSString.h>

#import "SOGoUserProfile.h"
#import "NSString+Crypto.h"

#import "SOGoUserSettings.h"

Expand Down Expand Up @@ -68,4 +70,28 @@ - (NSArray *) subscribedAddressBooks
return [self _subscribedFoldersForModule: @"Contacts"];
}

- (NSString *) userSalt
{
NSMutableDictionary *values;
NSString *salt;

salt = [[self dictionaryForKey: @"General"] objectForKey: @"Salt"];

if (!salt)
{
salt = [[[NSProcessInfo processInfo] globallyUniqueString] asSHA1String];
values = [self objectForKey: @"General"];

if (!values)
values = [NSMutableDictionary dictionary];

[values setObject: salt forKey: @"Salt"];
[self setObject: values forKey: @"General"];
[self synchronize];
}

return salt;
}


@end

0 comments on commit 875a4ac

Please sign in to comment.