mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-11 00:08:51 +00:00
sogo-mail: Priorize filename attribute to get attachment name
Some clients (such apple mail) use only the filename attribute in the content/disposition header and the name attribute from the content/type header is filled with uninternationalized characters. Example: Content-Type: application/msword; x-apple-part-url=C4977556-0D01-4C6C-8A51-451E0AADE431; name=_______.doc Content-Disposition: attachment; filename*=utf-8''%D0%A0%D0%95%D0%9A%D0%92%D0%98%D0%97%D0%98.doc This changeset gives priority to the filename attribute.
This commit is contained in:
@@ -30,14 +30,13 @@
|
||||
{
|
||||
NSDictionary *parameters;
|
||||
NSString *filename;
|
||||
|
||||
filename = [[self objectForKey: @"parameterList"]
|
||||
objectForKey: @"name"];
|
||||
|
||||
if (!filename)
|
||||
|
||||
filename = nil;
|
||||
parameters = [[self objectForKey: @"disposition"]
|
||||
objectForKey: @"parameterList"];
|
||||
|
||||
if (parameters)
|
||||
{
|
||||
parameters = [[self objectForKey: @"disposition"]
|
||||
objectForKey: @"parameterList"];
|
||||
filename = [parameters objectForKey: @"filename"];
|
||||
|
||||
|
||||
@@ -45,29 +44,33 @@
|
||||
// See RFC2231 for details. If it was folded before, it will
|
||||
// be unfolded when we get here.
|
||||
if (!filename)
|
||||
{
|
||||
filename = [parameters objectForKey: @"filename*"];
|
||||
|
||||
if (filename)
|
||||
{
|
||||
NSRange r;
|
||||
|
||||
filename = [filename stringByUnescapingURL];
|
||||
|
||||
// We skip up to the language
|
||||
r = [filename rangeOfString: @"'"];
|
||||
|
||||
if (r.length)
|
||||
{
|
||||
r = [filename rangeOfString: @"'" options: 0 range: NSMakeRange(r.location+1, [filename length]-r.location-1)];
|
||||
|
||||
if (r.length)
|
||||
filename = [filename substringFromIndex: r.location+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
filename = [parameters objectForKey: @"filename*"];
|
||||
|
||||
if (filename)
|
||||
{
|
||||
NSRange r;
|
||||
|
||||
filename = [filename stringByUnescapingURL];
|
||||
|
||||
// We skip up to the language
|
||||
r = [filename rangeOfString: @"'"];
|
||||
|
||||
if (r.length)
|
||||
{
|
||||
r = [filename rangeOfString: @"'" options: 0 range: NSMakeRange(r.location+1, [filename length]-r.location-1)];
|
||||
|
||||
if (r.length)
|
||||
filename = [filename substringFromIndex: r.location+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!filename)
|
||||
filename = [[self objectForKey: @"parameterList"]
|
||||
objectForKey: @"name"];
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user