View Issue Details

IDProjectCategoryView StatusLast Update
0002810SOGoActiveSyncpublic2014-06-26 15:02
Reporterandrew Assigned Toludovic  
PrioritynormalSeveritymajorReproducibilityhave not tried
Status resolvedResolutionfixed 
Target Version2.2.6Fixed in Version2.2.6 
Summary0002810: ActiveSync gb2312 mail charset problem
Description

1?In Android, mail content and header display is normal by charset utf-8; mail header display is too normal by charset gb2312. But mail content display is unnormally by charset gb2312. Outlook 2013 is all normal.

2?Some mail content character include gbk or gb18030 and exclude gb2312 character ,but charset was set gb2312 by Outlook. Webmail and Outlook 2013 will show content and header unnormal. I suggest using gb18030 to decode gb2312 and gbk.

TagsNo tags attached.

Activities

andrew

andrew

2014-06-10 13:17

reporter   ~0007172

Last edited: 2014-06-10 13:18

For 2, after edit static function iconv_wrapper in file sope-core/NGExtensions/FdExt.subproj/NSString+Encoding.m:

if([ _fromEncode isEqualString: @"GB2312"])
_fromEncode = @'GB18030';
else if([ _fromEncode isEqualString: @"GBK"])
_fromEncode = @'GB18030';

Webmail show normal,but activesync still exist the problem.

andrew

andrew

2014-06-12 17:23

reporter   ~0007204

Last edited: 2014-06-12 17:24

I think the attach file can resolve the problem,not just chinese language but also others, especially east Asia language in activesync.

andrew

andrew

2014-06-12 17:23

reporter  

ludovic

ludovic

2014-06-16 19:38

administrator   ~0007217

Can you provide the changes as a "diff -u" ?

andrew

andrew

2014-06-17 02:03

reporter  

SOGoMailObject+ActiveSync.m.diff (2,539 bytes)   
--- sogo-master/ActiveSync/SOGoMailObject+ActiveSync.m	2014-06-12 21:09:08.000000000 +0800
+++ sogo20140613/ActiveSync/SOGoMailObject+ActiveSync.m	2014-06-13 00:58:40.291509895 +0800
@@ -246,6 +246,12 @@
         d = [d dataByDecodingBase64];
       else if ([encoding caseInsensitiveCompare: @"quoted-printable"] == NSOrderedSame)
         d = [d dataByDecodingQuotedPrintableTransferEncoding];
+
+      NSString *s,*charset;
+      charset = [[[self lookupInfoForBodyPart: key] objectForKey: @"parameterList"] objectForKey: @"charset"];
+      if(![charset length]) charset = @"us-ascii";
+      s = [NSString stringWithData: d usingEncodingNamed: charset];
+      d = [s dataUsingEncoding: NSUTF8StringEncoding];
     }
 
   return d;
@@ -300,9 +306,10 @@
 
               charset = [[thePart contentType] valueOfParameter: @"charset"];
               encoding = [NGMimeType stringEncodingForCharset: charset];
-              
-              s = [[NSString alloc] initWithData: body  encoding: encoding];
-              AUTORELEASE(s);
+
+              s = [NSString stringWithData: body usingEncodingNamed: charset];     
+              //s = [[NSString alloc] initWithData: body  encoding: encoding];
+              //AUTORELEASE(s);
             }
           else
             {
@@ -396,6 +403,10 @@
     {
       if ([type isEqualToString: @"text"])
         {
+          NSString *s, *charset;
+          charset = [[[self lookupInfoForBodyPart: @""] objectForKey: @"parameterList"] objectForKey: @"charset"];
+          if(![charset length]) charset = @"us-ascii";
+          
           d = [[self fetchPlainTextParts] objectForKey: @""];
           
           // We check if we have base64 encoded parts. If so, we just
@@ -407,17 +418,13 @@
           else if ([encoding caseInsensitiveCompare: @"quoted-printable"] == NSOrderedSame)
             d = [d dataByDecodingQuotedPrintableTransferEncoding];
 
+          s = [NSString stringWithData: d usingEncodingNamed: charset];
           // Check if we must convert html->plain
           if (theType == 1 && [subtype isEqualToString: @"html"])
             {
-              NSString *s;
-              
-              s = [[NSString alloc] initWithData: d  encoding: NSUTF8StringEncoding];
-              AUTORELEASE(s);
-
               s = [s htmlToText];
-              d = [s dataUsingEncoding: NSUTF8StringEncoding];
             }
+            d = [s dataUsingEncoding: NSUTF8StringEncoding];
         }
       else if ([type isEqualToString: @"multipart"])
         {
ludovic

ludovic

2014-06-26 15:02

administrator   ~0007245

Fix pushed - thanks for your contribution.

https://github.com/inverse-inc/sogo/commit/b6be4e6e2fb8e00c8f0b29e4f493936d0fcfbb2e

Issue History

Date Modified Username Field Change
2014-06-10 12:54 andrew New Issue
2014-06-10 13:17 andrew Note Added: 0007172
2014-06-10 13:17 andrew Note Edited: 0007172
2014-06-10 13:18 andrew Note Edited: 0007172
2014-06-12 17:23 andrew Note Added: 0007204
2014-06-12 17:23 andrew File Added: SOGoMailObject+ActiveSync.m
2014-06-12 17:24 andrew Note Edited: 0007204
2014-06-16 19:38 ludovic Note Added: 0007217
2014-06-16 19:38 ludovic Target Version => 2.2.6
2014-06-17 02:03 andrew File Added: SOGoMailObject+ActiveSync.m.diff
2014-06-26 15:02 ludovic Note Added: 0007245
2014-06-26 15:02 ludovic Status new => resolved
2014-06-26 15:02 ludovic Fixed in Version => 2.2.6
2014-06-26 15:02 ludovic Resolution open => fixed
2014-06-26 15:02 ludovic Assigned To => ludovic