From 3a56cda1cedf851a7ecc91f66e9468a5e92cc9cb Mon Sep 17 00:00:00 2001 From: CaS Date: Fri, 6 Aug 2004 13:26:25 +0000 Subject: [PATCH] When parsing documents with non-standard charset, set the charset actually used in the content type so that we can unparse the data properly too. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19831 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Source/Additions/GSMime.m | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/ChangeLog b/ChangeLog index 739dcdf36..fbb48d6c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-05-30 Richard Frith-Macdonald + + * Source/GSMime.m: When using non-ascii default characterset + ensure that the content type header has the appropriate + charset parameter added during parsing, so unparsing will + work correctly. + 2004-08-05 01:59 Alexander Malmberg * Source/NSDistantObject.m (DO_FORWARD_INVOCATION): Warning if we diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index 21d6883fb..ceb463bfd 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -2242,6 +2242,27 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info); if (typeInfo == nil) { stringEncoding = _defaultEncoding; + if (stringEncoding != NSASCIIStringEncoding) + { + NSString *charset; + + if (typeInfo == nil) + { + typeInfo = [GSMimeHeader new]; + [typeInfo setName: @"content-type"]; + [typeInfo setValue: @"text/plain"]; + [typeInfo setObject: @"text" + forKey: @"Type"]; + [typeInfo setObject: @"plain" + forKey: @"Subtype"]; + [document setHeader: typeInfo]; + RELEASE(typeInfo); + } + charset = [GSMimeDocument charsetFromEncoding: + stringEncoding]; + [typeInfo setParameter: charset + forKey: @"charset"]; + } } else {