see changelog

Monotone-Parent: a9323afc29bd494143d2c78639e7a02f3d3804cb
Monotone-Revision: 1af347fe96abc17587172e207fcbf80e98d7f6f8

Monotone-Author: ludovic@Sophos.ca
Monotone-Date: 2008-08-22T13:52:24
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Ludovic Marcotte 2008-08-22 13:52:24 +00:00
parent c10afe743c
commit 98d6032638
5 changed files with 51 additions and 11 deletions

View file

@ -1,3 +1,9 @@
2008-08-22 Ludovic Marcotte <lmarcotte@inverse.ca>
* Modified SoObjects/Mailer/NSData+Mail.m
-decodedSubject so we correctly implement decoding
instead of relying on the broken SOPE implementation.
2008-08-21 Ludovic Marcotte <lmarcotte@inverse.ca> 2008-08-21 Ludovic Marcotte <lmarcotte@inverse.ca>
* SoObjects/SOGo/LDAPUserManager.m * SoObjects/SOGo/LDAPUserManager.m

View file

@ -1,8 +1,9 @@
/* NSData+Mail.m - this file is part of SOGo /* NSData+Mail.m - this file is part of SOGo
* *
* Copyright (C) 2007 Inverse groupe conseil * Copyright (C) 2007-2008 Inverse inc.
* *
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca> * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Ludovic Marcotte <lmarcotte@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -56,7 +57,7 @@
{ {
const char *cData, *endFlag; const char *cData, *endFlag;
unsigned int len; unsigned int len;
NSString *converted, *decodedSubject; NSString *decodedSubject;
cData = [self bytes]; cData = [self bytes];
len = [self length]; len = [self length];
@ -70,14 +71,37 @@
if (*cData == '=' && *(cData + 1) == '?' if (*cData == '=' && *(cData + 1) == '?'
&& *endFlag == '?' && *(endFlag + 1) == '=') && *endFlag == '?' && *(endFlag + 1) == '=')
{ {
converted NSString *enc;
= [[NSString alloc] initWithData: self int i;
encoding: NSASCIIStringEncoding];
if (converted) cData += 2;
i = 2;
while (*cData != '?' && i < len)
{ {
[converted autorelease]; cData++;
decodedSubject = [converted stringByDecodingQuotedPrintable]; i++;
} }
enc = [[[NSString alloc] initWithData:[self subdataWithRange: NSMakeRange(2, i-2)]
encoding: NSASCIIStringEncoding] autorelease];
if (i+3 < len)
{
NSData *d;
d = [self subdataWithRange: NSMakeRange(i+3, len-i-5)];
// We check if we have a QP or Base64 encoding
if (*(cData+1) == 'q' || *(cData+1) == 'Q')
d = [d dataByDecodingQuotedPrintable];
else
d = [d dataByDecodingBase64];
decodedSubject = [NSString stringWithData: d usingEncodingNamed: enc];
}
else
decodedSubject = nil;
} }
} }
if (!decodedSubject) if (!decodedSubject)

View file

@ -1,6 +1,6 @@
/* NSString+Mail.m - this file is part of SOGo /* NSString+Mail.m - this file is part of SOGo
* *
* Copyright (C) 2007 Inverse groupe conseil * Copyright (C) 2008 Inverse inc.
* *
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca> * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
@ -33,6 +33,7 @@
#import <NGExtensions/NSObject+Logs.h> #import <NGExtensions/NSObject+Logs.h>
#import "NSString+Mail.h" #import "NSString+Mail.h"
#import "NSData+Mail.h"
#if 1 #if 1
#define showWhoWeAre() \ #define showWhoWeAre() \
@ -369,7 +370,8 @@
if ([self hasPrefix: @"=?"] && [self hasSuffix: @"?="]) if ([self hasPrefix: @"=?"] && [self hasSuffix: @"?="])
{ {
decodedSubject = [self stringByDecodingQuotedPrintable]; decodedSubject = [[self dataUsingEncoding: NSASCIIStringEncoding]
decodedSubject];
if (!decodedSubject) if (!decodedSubject)
decodedSubject = self; decodedSubject = self;
} }

View file

@ -1,6 +1,6 @@
/* NSString+Utilities.m - this file is part of SOGo /* NSString+Utilities.m - this file is part of SOGo
* *
* Copyright (C) 2006 Inverse groupe conseil * Copyright (C) 2006-2008 Inverse inc.
* *
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca> * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *

View file

@ -22,6 +22,8 @@
#import <NGImap4/NGImap4Envelope.h> #import <NGImap4/NGImap4Envelope.h>
#import <NGImap4/NGImap4EnvelopeAddress.h> #import <NGImap4/NGImap4EnvelopeAddress.h>
#import <NGExtensions/NSString+Encoding.h>
#import <SoObjects/Mailer/NSData+Mail.h> #import <SoObjects/Mailer/NSData+Mail.h>
#import <SoObjects/Mailer/NSString+Mail.h> #import <SoObjects/Mailer/NSString+Mail.h>
@ -154,7 +156,13 @@
NSString *subject; NSString *subject;
baseSubject = [[self envelope] subject]; baseSubject = [[self envelope] subject];
// We avoid uber-lamenesses in SOPE - see sope-core/NGExtensions/NGQuotedPrintableCoding.m
// -stringByDecodingQuotedPrintable for all details
if ([baseSubject isKindOfClass: [NSString class]])
baseSubject = [baseSubject dataUsingEncoding: NSASCIIStringEncoding];
subject = [baseSubject decodedSubject]; subject = [baseSubject decodedSubject];
if (![subject length]) if (![subject length])
subject = [self labelForKey: @"Untitled"]; subject = [self labelForKey: @"Untitled"];