(feat) added new SOGoMaximumMessageSizeLimit config parameter (fixes #3510)
Conflicts: SoObjects/Mailer/SOGoDraftObject.mpull/232/head
parent
7c7440c988
commit
2cebee42b7
|
@ -394,6 +394,11 @@ attachment size being uploaded to SOGo when composing a mail. The
|
|||
value is in kilobyte. By default, the value is 0, or disabled so no
|
||||
limit will be set.
|
||||
|
||||
|S |SOGoMaximumMessageSizeLimit
|
||||
|Parameter used to set the maximum allowed email message size when
|
||||
composing a mail. The value is in kilobyte. By default, the value is 0,
|
||||
or disabled so no limit will be set.
|
||||
|
||||
|S |SxVMemLimit
|
||||
|Parameter used to set the maximum amount of memory (in
|
||||
megabytes) that a child can use. Reaching that value will force children
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
#import <SOGo/SOGoMailer.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserFolder.h>
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
#import <SOGo/SOGoSystemDefaults.h>
|
||||
|
||||
#import <NGCards/NGVCard.h>
|
||||
|
||||
|
@ -641,6 +643,12 @@ static NSString *userAgent = nil;
|
|||
error = nil;
|
||||
message = [self mimeMessageAsData];
|
||||
|
||||
if (!message)
|
||||
{
|
||||
error = [NSException exceptionWithHTTPStatus: 500 /* Server Error */
|
||||
reason: @"message too big"];
|
||||
}
|
||||
|
||||
client = [[self imap4Connection] client];
|
||||
|
||||
if (![imap4 doesMailboxExistAtURL: [container imap4URL]])
|
||||
|
@ -1368,18 +1376,27 @@ static NSString *userAgent = nil;
|
|||
}
|
||||
|
||||
//
|
||||
//
|
||||
// returns nil on error
|
||||
//
|
||||
- (NSArray *) bodyPartsForAllAttachments
|
||||
{
|
||||
/* returns nil on error */
|
||||
NSArray *attrs;
|
||||
unsigned i, count;
|
||||
NGMimeBodyPart *bodyPart;
|
||||
NSMutableArray *bodyParts;
|
||||
NSArray *attrs;
|
||||
unsigned i, count, size, limit;
|
||||
|
||||
attrs = [self fetchAttachmentAttrs];
|
||||
count = [attrs count];
|
||||
size = 0;
|
||||
|
||||
// We first check if we don't go over our message size limit
|
||||
limit = [[SOGoSystemDefaults sharedSystemDefaults] maximumMessageSizeLimit] * 1024;
|
||||
for (i = 0; i < count; i++)
|
||||
size += [[[attrs objectAtIndex: i] objectForKey: @"size"] intValue];
|
||||
|
||||
if (limit && size > limit)
|
||||
return nil;
|
||||
|
||||
bodyParts = [NSMutableArray arrayWithCapacity: count];
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
|
@ -1437,13 +1454,9 @@ static NSString *userAgent = nil;
|
|||
mBody = [[NGMimeMultipartBody alloc] initWithPart: message];
|
||||
|
||||
if (!isHTML)
|
||||
{
|
||||
part = [self bodyPartForText];
|
||||
}
|
||||
part = [self bodyPartForText];
|
||||
else
|
||||
{
|
||||
part = [self mimeMultipartAlternative];
|
||||
}
|
||||
part = [self mimeMultipartAlternative];
|
||||
|
||||
[mBody addBodyPart: part];
|
||||
|
||||
|
@ -1644,8 +1657,10 @@ static NSString *userAgent = nil;
|
|||
{
|
||||
NSMutableArray *bodyParts;
|
||||
NGMimeMessage *message;
|
||||
NSArray *allBodyParts;
|
||||
NGMutableHashMap *map;
|
||||
NSString *newText;
|
||||
|
||||
BOOL has_inline_images;
|
||||
|
||||
message = nil;
|
||||
|
@ -1667,8 +1682,12 @@ static NSString *userAgent = nil;
|
|||
if (map)
|
||||
{
|
||||
//[self debugWithFormat: @"MIME Envelope: %@", map];
|
||||
allBodyParts = [self bodyPartsForAllAttachments];
|
||||
|
||||
[bodyParts addObjectsFromArray: [self bodyPartsForAllAttachments]];
|
||||
if (!allBodyParts)
|
||||
return nil;
|
||||
|
||||
[bodyParts addObjectsFromArray: allBodyParts];
|
||||
|
||||
//[self debugWithFormat: @"attachments: %@", bodyParts];
|
||||
|
||||
|
@ -1709,10 +1728,19 @@ static NSString *userAgent = nil;
|
|||
- (NSData *) mimeMessageAsData
|
||||
{
|
||||
NGMimeMessageGenerator *generator;
|
||||
NGMimeMessage *mimeMessage;
|
||||
NSData *message;
|
||||
|
||||
generator = [NGMimeMessageGenerator new];
|
||||
message = [generator generateMimeFromPart: [self mimeMessageWithHeaders: nil excluding: nil extractingImages: NO]];
|
||||
mimeMessage = [self mimeMessageWithHeaders: nil excluding: nil extractingImages: NO];
|
||||
|
||||
if (!mimeMessage)
|
||||
{
|
||||
[generator release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
message = [generator generateMimeFromPart: mimeMessage];
|
||||
[generator release];
|
||||
|
||||
return message;
|
||||
|
|
|
@ -94,6 +94,8 @@
|
|||
- (int) maximumFailedLoginInterval;
|
||||
- (int) failedLoginBlockInterval;
|
||||
|
||||
- (int) maximumMessageSizeLimit;
|
||||
|
||||
- (int) maximumMessageSubmissionCount;
|
||||
- (int) maximumRecipientCount;
|
||||
- (int) maximumSubmissionInterval;
|
||||
|
|
|
@ -578,6 +578,14 @@ _injectConfigurationFromFile (NSMutableDictionary *defaultsDict,
|
|||
return v;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
- (int) maximumMessageSizeLimit
|
||||
{
|
||||
return [self integerForKey: @"SOGoMaximumMessageSizeLimit"];
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue