From 933cd581ddd9625f1f758736e7cc9eec43c7a799 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 18 Mar 2019 10:28:33 -0400 Subject: [PATCH] (fix) avoid exception on recent GNUstep when attached file has no filename (fixes #4702) --- NEWS | 1 + UI/MailPartViewers/UIxMailPartViewer.m | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 680bf20a88..11acbff25b 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ Bug fixes - [core] allow super users to modify any event (#4216) - [core] correctly handle the full cert chain in S/MIME - [core] handle multidays events in freebusy data + - [core] avoid exception on recent GNUstep when attached file has no filename (#4702) 4.0.7 (2019-02-27) ------------------ diff --git a/UI/MailPartViewers/UIxMailPartViewer.m b/UI/MailPartViewers/UIxMailPartViewer.m index 78f1aa22e0..5eb2515f89 100644 --- a/UI/MailPartViewers/UIxMailPartViewer.m +++ b/UI/MailPartViewers/UIxMailPartViewer.m @@ -36,6 +36,7 @@ #import #import #import +#import #import "MailerUI/WOContext+UIxMailer.h" #import "UIxMailRenderingContext.h" @@ -303,15 +304,14 @@ - (NSString *) _filenameForAttachment: (SOGoMailBodyPart *) bodyPart NSMutableString *filename; NSString *extension; - filename = [NSMutableString stringWithString: [self filename]]; - if ([filename length]) + if ([[self filename] length]) // We replace any slash by a dash since Apache won't allow encoded slashes by default. // See http://httpd.apache.org/docs/2.2/mod/core.html#allowencodedslashes - filename = [NSMutableString stringWithString: [filename stringByReplacingString: @"/" withString: @"-"]]; + filename = [NSMutableString stringWithString: [[self filename] stringByReplacingString: @"/" withString: @"-"]]; else - [filename appendFormat: @"%@-%@", - [self labelForKey: @"Untitled"], - [bodyPart nameInContainer]]; + filename = [NSMutableString stringWithFormat: @"%@-%@", + [self labelForKey: @"Untitled"], + [bodyPart nameInContainer]]; if (![[filename pathExtension] length]) {