Skip to content
Permalink
Browse files

(fix) improved previous commit for attributes stripping and UID gener…

…ation (fixes #3695 and #3696)

Conflicts:

	SoObjects/Appointments/SOGoCalendarComponent.m
  • Loading branch information...
extrafu committed May 27, 2016
1 parent c9c08c1 commit 717f45f640a2866b76a8984139391fae64339225
@@ -47,6 +47,7 @@
#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/SOGoDomainDefaults.h>
@@ -55,6 +56,7 @@
#import <SOGo/SOGoPermissions.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
#import <SOGo/SOGoUserSettings.h>
#import <SOGo/SOGoSystemDefaults.h>
#import <SOGo/SOGoUserManager.h>
#import <SOGo/SOGoWebDAVAclManager.h>
@@ -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";

@@ -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
@@ -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
@@ -33,6 +33,7 @@

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

@end

@@ -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
@@ -20,9 +20,11 @@

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

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

#import "SOGoUserSettings.h"

@@ -69,4 +71,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 717f45f

Please sign in to comment.
You can’t perform that action at this time.