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"]; }