mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-02 10:05:26 +00:00
(fix) remaining S/MIME fixes to handle image/CIDs in HTML mails
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2007-2016 Inverse inc.
|
||||
Copyright (C) 2007-2018 Inverse inc.
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of SOGo.
|
||||
@@ -799,6 +799,12 @@ static NSString *userAgent = nil;
|
||||
//
|
||||
- (void) _fileAttachmentsFromPart: (id) thePart
|
||||
{
|
||||
// Small hack to avoid SOPE's stupid behavior to wrap a multipart
|
||||
// object in a NGMimeBodyPart.
|
||||
if ([thePart isKindOfClass: [NGMimeBodyPart class]] &&
|
||||
[[[thePart contentType] type] isEqualToString: @"multipart"])
|
||||
thePart = [thePart body];
|
||||
|
||||
if ([thePart isKindOfClass: [NGMimeBodyPart class]])
|
||||
{
|
||||
NSString *filename, *mimeType;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#import <NGMime/NGMimeMultipartBody.h>
|
||||
|
||||
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
|
||||
#import <SoObjects/SOGo/NSObject+Utilities.h>
|
||||
|
||||
#import "NSData+SMIME.h"
|
||||
#import "NSDictionary+Mail.h"
|
||||
@@ -169,35 +170,65 @@ static BOOL debugOn = NO;
|
||||
inContext: (WOContext *) localContext
|
||||
{
|
||||
// TODO: we might want to check for existence prior controller creation
|
||||
Class clazz;
|
||||
NSArray *subParts;
|
||||
unsigned int nbr;
|
||||
id obj;
|
||||
NSDictionary *subPart, *infos;
|
||||
NSString *mimeType;
|
||||
NSArray *subParts;
|
||||
Class clazz;
|
||||
id o, obj;
|
||||
|
||||
unsigned int nbr;
|
||||
|
||||
nbr = [key intValue];
|
||||
infos = [self partInfo];
|
||||
subParts = [infos objectForKey: @"parts"];
|
||||
if (!subParts)
|
||||
subParts = [[infos objectForKey: @"body"] objectForKey: @"parts"];
|
||||
o = [self container];
|
||||
|
||||
if (nbr > 0 && nbr < ([subParts count] + 1))
|
||||
while (![o isKindOfClass: [SOGoMailObject class]])
|
||||
o = [o container];
|
||||
|
||||
if ([o isEncrypted])
|
||||
{
|
||||
subPart = [subParts objectAtIndex: nbr - 1];
|
||||
clazz
|
||||
= [[self class] bodyPartClassForMimeType:
|
||||
[subPart keysWithFormat: @"%{type}/%{subtype}"]
|
||||
inContext: localContext];
|
||||
obj = [clazz objectWithName: key inContainer: self];
|
||||
NSData *certificate;
|
||||
NGMimeMessage *m;
|
||||
id part;
|
||||
|
||||
int i;
|
||||
|
||||
certificate = [[self mailAccountFolder] certificate];
|
||||
m = [[o content] messageFromEncryptedDataAndCertificate: certificate];
|
||||
part = [m body];
|
||||
|
||||
for (i = 0; i < [[self bodyPartPath] count]; i++)
|
||||
{
|
||||
nbr = [[[self bodyPartPath] objectAtIndex: i] intValue]-1;
|
||||
part = [[part parts] objectAtIndex: nbr];;
|
||||
}
|
||||
|
||||
//part = [[[m body] parts] objectAtIndex: ([key intValue]-1)];
|
||||
part = [[part parts] objectAtIndex: ([key intValue]-1)];
|
||||
mimeType = [[part contentType] stringValue];
|
||||
clazz = [SOGoMailBodyPart bodyPartClassForMimeType: mimeType
|
||||
inContext: localContext];
|
||||
obj = [clazz objectWithName:key inContainer: self];
|
||||
}
|
||||
else
|
||||
obj = self;
|
||||
{
|
||||
infos = [self partInfo];
|
||||
subParts = [infos objectForKey: @"parts"];
|
||||
if (!subParts)
|
||||
subParts = [[infos objectForKey: @"body"] objectForKey: @"parts"];
|
||||
|
||||
return obj;
|
||||
// clazz = [SOGoMailBodyPart bodyPartClassForKey: _key
|
||||
// inContext: _ctx];
|
||||
if (nbr > 0 && nbr < ([subParts count] + 1))
|
||||
{
|
||||
subPart = [subParts objectAtIndex: nbr - 1];
|
||||
mimeType = [subPart keysWithFormat: @"%{type}/%{subtype}"];
|
||||
clazz = [[self class] bodyPartClassForMimeType: mimeType
|
||||
inContext: localContext];
|
||||
obj = [clazz objectWithName: key inContainer: self];
|
||||
}
|
||||
else
|
||||
obj = self;
|
||||
}
|
||||
|
||||
// return [clazz objectWithName: _key inContainer: self];
|
||||
return obj;
|
||||
}
|
||||
|
||||
- (NSString *) filename
|
||||
@@ -304,23 +335,29 @@ static BOOL debugOn = NO;
|
||||
if ([o isEncrypted])
|
||||
{
|
||||
NSData *certificate;
|
||||
NGMimeMessage *m;
|
||||
id part;
|
||||
|
||||
unsigned int i, nbr;
|
||||
|
||||
// No need to check if the cert is valid as we already do so
|
||||
// in SOGoMailObject.
|
||||
certificate = [[self mailAccountFolder] certificate];
|
||||
|
||||
// If we got a user certificate, let's use it. Otherwise we fallback
|
||||
// to the current BLOB fetching code.
|
||||
if (certificate)
|
||||
m = [[o content] messageFromEncryptedDataAndCertificate: certificate];
|
||||
part = [m body];
|
||||
|
||||
for (i = 0; i < [[self bodyPartPath] count]; i++)
|
||||
{
|
||||
NGMimeMessage *m;
|
||||
id part;
|
||||
|
||||
m = [[container content] messageFromEncryptedDataAndCertificate: certificate];
|
||||
part = [[[m body] parts] objectAtIndex: ([[self nameInContainer] intValue]-1)];
|
||||
|
||||
return [part body];
|
||||
nbr = [[[self bodyPartPath] objectAtIndex: i] intValue]-1;
|
||||
part = [[part parts] objectAtIndex: nbr];;
|
||||
}
|
||||
|
||||
return [part body];
|
||||
}
|
||||
|
||||
// The mail is not encrypted, lets fetch the body party normally
|
||||
// straight from the IMAP server
|
||||
return [self fetchBLOBWithPeek: NO];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* NSObject+Utilities.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007-2015 Inverse inc.
|
||||
* Copyright (C) 2007-2017 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
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#import <DOM/DOMProtocols.h>
|
||||
|
||||
@class NSArray;
|
||||
@class NSString;
|
||||
@class WOContext;
|
||||
|
||||
@@ -39,6 +40,8 @@
|
||||
|
||||
+ (void) memoryStatistics;
|
||||
|
||||
- (NSArray *) parts;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* NSOBJECT+UTILITIES_H */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* NSObject+Utilities.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007-2015 Inverse inc.
|
||||
* Copyright (C) 2007-2018 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
|
||||
@@ -24,6 +24,9 @@
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
|
||||
#import <NGMime/NGMimeBodyPart.h>
|
||||
#import <NGMime/NGMimeMultipartBody.h>
|
||||
|
||||
#import "NSDictionary+Utilities.h"
|
||||
#import "SOGoUser.h"
|
||||
#import "SOGoUserDefaults.h"
|
||||
@@ -147,4 +150,20 @@
|
||||
printf("Done!\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Small hack to avoid SOPE's stupid behavior to wrap a multipart
|
||||
// object in a NGMimeBodyPart.
|
||||
//
|
||||
- (NSArray *) parts
|
||||
{
|
||||
if ([self isKindOfClass: [NGMimeMultipartBody class]])
|
||||
return [self parts];
|
||||
|
||||
if ([self isKindOfClass: [NGMimeBodyPart class]] &&
|
||||
[[(id)self body] isKindOfClass: [NGMimeMultipartBody class]])
|
||||
return [[(id)self body] parts];
|
||||
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user