diff --git a/NEWS b/NEWS index 7f500f1cf..9a2ffc2d2 100644 --- a/NEWS +++ b/NEWS @@ -43,6 +43,7 @@ Bug fixes - encode HTML entities in JSON data returned by Calendar module (#2598) - fixed handling of ACLs on shared calendars with multiple groups (#1854) - fixed HTML formatting of appointment notifications for Outlook (#2233) + - replace slashes by dashes in filenames of attachments to avoid a 404 return code (#2537) 2.1.1b (2013-12-04) ------------------- diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index aa808d196..85eacf5b9 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -761,7 +761,7 @@ static BOOL debugSoParts = NO; withPath: (NSString *) path andPrefix: (NSString *) prefix { - NSString *filename, *mimeType; + NSString *filename, *mimeType, *filenameURL; NSDictionary *currentFile; filename = [part filename]; @@ -783,14 +783,18 @@ static BOOL debugSoParts = NO; if (filename) { + // 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 + // See [UIxMailPartViewer _filenameForAttachment:] + filenameURL = [[filename stringByReplacingString: @"/" withString: @"-"] stringByEscapingURL]; currentFile = [NSDictionary dictionaryWithObjectsAndKeys: filename, @"filename", [mimeType lowercaseString], @"mimetype", path, @"path", [part objectForKey: @"encoding"], @"encoding", [part objectForKey:@ "size"], @"size", - [NSString stringWithFormat: @"%@/%@", prefix, [filename stringByEscapingURL]], @"url", - [NSString stringWithFormat: @"%@/asAttachment/%@", prefix, [filename stringByEscapingURL]], @"urlAsAttachment", + [NSString stringWithFormat: @"%@/%@", prefix, filenameURL], @"url", + [NSString stringWithFormat: @"%@/asAttachment/%@", prefix, filenameURL], @"urlAsAttachment", nil]; [keys addObject: currentFile]; } diff --git a/UI/MailPartViewers/UIxMailPartViewer.m b/UI/MailPartViewers/UIxMailPartViewer.m index 21aeec623..c973acbb6 100644 --- a/UI/MailPartViewers/UIxMailPartViewer.m +++ b/UI/MailPartViewers/UIxMailPartViewer.m @@ -267,7 +267,11 @@ NSString *extension; filename = [NSMutableString stringWithString: [self filename]]; - if (![filename length]) + if ([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 = [filename stringByReplacingString: @"/" withString: @"-"]; + else [filename appendFormat: @"%@-%@", [self labelForKey: @"Untitled"], [bodyPart nameInContainer]];