From 819c3bcab4216d4e08316355d0c688bf3120ca07 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 21 Sep 2009 17:27:41 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: 58575b53d5a371c107121b592dfc764b7917d986 Monotone-Revision: 35156d431d203984a125b3638bbea9d7877ed199 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2009-09-21T17:27:41 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ .../versitCardsSaxDriver/VSSaxDriver.m | 22 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd51f049d..692b43112 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-21 Ludovic Marcotte + + * SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m + Avoid lameness when handling QP-encoded content. + 2009-09-21 Wolfgang Sourdeau * UI/WebServerResources/MailerUI.js (updateMailboxTreeInPage): diff --git a/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m b/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m index fef59b9b4..c06a370c3 100644 --- a/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m +++ b/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m @@ -31,6 +31,7 @@ #import "VSSaxDriver.h" #import #import +#import #import #import "common.h" @@ -860,8 +861,25 @@ static NSCharacterSet *whitespaceCharSet = nil; // TODO: make the encoding check more generic if ([tagAttributes containsObject: @"ENCODING=QUOTED-PRINTABLE"]) { - // TODO: QP is charset specific! The one below decodes in Unicode! - tagValue = [tagValue stringByDecodingQuotedPrintable]; + NSString *charset; + NSData *d; + int i; + + d = [[tagValue dataUsingEncoding: NSASCIIStringEncoding] + dataByDecodingQuotedPrintable]; + + // Let's find the charset. + charset = @"utf-8"; + + for (i = 0; i < [tagAttributes count]; i++) + { + charset = [[tagAttributes objectAtIndex: i] lowercaseString]; + + if ([charset hasPrefix: @"charset"]) + charset = [charset substringFromIndex: 8]; + } + + tagValue = [NSString stringWithData: d usingEncodingNamed: charset]; [tagAttributes removeObject: @"ENCODING=QUOTED-PRINTABLE"]; }