From 38b012e072f808393f87f5cc3059fab7072fb8b7 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 08 Feb 2008 12:33:08 -0500
Subject: [PATCH] Added some charset aliases to fix typical mis-labelling (#1484565)

---
 program/include/main.inc |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index 1e25dd6..9e33bae 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -562,7 +562,7 @@
   if ($a_host['host'])
     {
     $host = $a_host['host'];
-    $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? TRUE : FALSE;
+    $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null;
     $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $CONFIG['default_port']);
     }
   else
@@ -907,18 +907,26 @@
 
   if ($from==$to || $str=='' || empty($from))
     return $str;
+    
+  $aliases = array(
+    'UNKNOWN-8BIT'   => 'ISO-8859-15',
+    'X-UNKNOWN'      => 'ISO-8859-15',
+    'X-USER-DEFINED' => 'ISO-8859-15',
+    'ISO-8859-8-I'   => 'ISO-8859-8',
+    'KS_C_5601-1987' => 'EUC-KR',
+    'GB2312'         => 'GB18030'
+  );
 
   // convert charset using iconv module  
   if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7')
     {
-    $iconv_map = array('KS_C_5601-1987' => 'EUC-KR');
-    return iconv(($iconv_map[$from] ? $iconv_map[$from] : $from), ($iconv_map[$to] ? $iconv_map[$to] : $to) . "//IGNORE", $str);
+    return iconv(($aliases[$from] ? $aliases[$from] : $from), ($aliases[$to] ? $aliases[$to] : $to) . "//IGNORE", $str);
     }
 
   // convert charset using mbstring module  
   if ($MBSTRING)
     {
-    $mb_map = array('UTF-7' => 'UTF7-IMAP', 'KS_C_5601-1987' => 'EUC-KR');
+    $mb_map = $aliases + array('UTF-7' => 'UTF7-IMAP');
     
     // return if convert succeeded
     if (($out = mb_convert_encoding($str, ($mb_map[$to] ? $mb_map[$to] : $to), ($mb_map[$from] ? $mb_map[$from] : $from))) != '')

--
Gitblit v1.9.1