Bug 1006498 - Use the charset manager to resolve aliases, r=Standard8, a=bustage-fix to reopen a CLOSED TREE.
authorJoshua Cranmer <Pidgeot18@gmail.com>
Tue, 13 May 2014 16:37:10 -0500
changeset 20102 d7b54421771a87961c5cdc65888efee9db2ac0b2
parent 20101 a232575572bb136e311042cd0b9a42d666bc57cc
child 20103 c0d49e4668ce56c001c0b10e865281762385480a
push id1179
push userCallek@gmail.com
push dateMon, 21 Jul 2014 20:52:37 +0000
treeherdercomm-beta@84d8ef10a503 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, bustage-fix
bugs1006498
Bug 1006498 - Use the charset manager to resolve aliases, r=Standard8, a=bustage-fix to reopen a CLOSED TREE.
mailnews/intl/charsetData.properties
mailnews/intl/test/unit/CharsetConversionTests.js
mailnews/intl/test/unit/test_bug718500.js
mailnews/intl/test/unit/xpcshell.ini
mailnews/mime/src/jsmime.jsm
--- a/mailnews/intl/charsetData.properties
+++ b/mailnews/intl/charsetData.properties
@@ -18,17 +18,16 @@
 ## charset_name.LangGroup = 
 ##
 ## charset_name.isMultibyte = multi byte charsets
 
 x-mac-arabic.isInternal                 = true
 x-mac-farsi.isInternal                  = true
 x-mac-hebrew.isInternal                 = true
 x-imap4-modified-utf7.isInternal        = true
-utf-7.isInternal                        = true
 t.61-8bit.isInternal                    = true
 ibm864.isInternal                       = true
 replacement.isInternal                  = true
 
 t.61-8bit.notForOutgoing                = true
 utf-7.notForOutgoing                    = true
 x-imap4-modified-utf7.notForOutgoing    = true
 us-ascii.notForOutgoing                 = true
--- a/mailnews/intl/test/unit/CharsetConversionTests.js
+++ b/mailnews/intl/test/unit/CharsetConversionTests.js
@@ -8,35 +8,41 @@ function CreateScriptableConverter()
     CC("@mozilla.org/intl/scriptableunicodeconverter",
        "nsIScriptableUnicodeConverter");
 
   return new ScriptableUnicodeConverter();
 }
 
 function checkDecode(converter, charset, inText, expectedText)
 {
+  let manager = Cc['@mozilla.org/charset-converter-manager;1']
+                  .getService(Ci.nsICharsetConverterManager);
+
   try {
-    converter.charset = charset;
+    converter.charset = manager.getCharsetAlias(charset);
   } catch(e) {
     converter.charset = "iso-8859-1";
   }
 
   dump("testing decoding from " + charset + " to Unicode.\n");
   try {
     var outText = converter.ConvertToUnicode(inText) + converter.Finish();
   } catch(e) {
     outText = "\ufffd";
   }
   do_check_eq(outText, expectedText);
 }
 
 function checkEncode(converter, charset, inText, expectedText)
 {
+  let manager = Cc['@mozilla.org/charset-converter-manager;1']
+                  .getService(Ci.nsICharsetConverterManager);
+
   try {
-    converter.charset = charset;
+    converter.charset = manager.getCharsetAlias(charset);
   } catch(e) {
     converter.charset = "iso-8859-1";
   }
 
   dump("testing encoding from Unicode to " + charset + "\n");
   var outText = converter.ConvertFromUnicode(inText) + converter.Finish();
   do_check_eq(outText, expectedText);
 }
deleted file mode 100644
--- a/mailnews/intl/test/unit/test_bug718500.js
+++ /dev/null
@@ -1,212 +0,0 @@
-var detectList = [
-  "chardet.universal_charset_detector",
-  "chardet.ja_parallel_state_machine",
-  "chardet.ko_parallel_state_machine",
-  "chardet.zhtw_parallel_state_machine",
-  "chardet.zhcn_parallel_state_machine",
-  "chardet.zh_parallel_state_machine",
-  "chardet.cjk_parallel_state_machine",
-  "chardet.off",
-  "chardet.ruprob",
-  "chardet.ukprob",
-];
-
-var encoderList = [
-  "ISO-8859-1",
-  "windows-1252",
-  "macintosh",
-  "UTF-8",
-  "us-ascii",
-  "ISO-8859-2",
-  "ISO-8859-3",
-  "ISO-8859-4",
-  "ISO-8859-5",
-  "ISO-8859-6",
-  "ISO-8859-6-I",
-  "ISO-8859-6-E",
-  "ISO-8859-7",
-  "ISO-8859-8",
-  "ISO-8859-8-I",
-  "ISO-8859-8-E",
-  "ISO-8859-9",
-  "ISO-8859-10",
-  "ISO-8859-13",
-  "ISO-8859-14",
-  "ISO-8859-15",
-  "ISO-8859-16",
-  "ISO-IR-111",
-  "windows-1250",
-  "windows-1251",
-  "windows-1253",
-  "windows-1254",
-  "windows-1255",
-  "windows-1256",
-  "windows-1257",
-  "windows-1258",
-  "TIS-620",
-  "windows-874",
-  "ISO-8859-11",
-  "KOI8-R",
-  "KOI8-U",
-  "x-mac-ce",
-  "x-mac-greek",
-  "x-mac-turkish",
-  "x-mac-croatian",
-  "x-mac-romanian",
-  "x-mac-cyrillic",
-  "x-mac-icelandic",
-  "armscii-8",
-  "x-viet-tcvn5712",
-  "VISCII",
-  "x-viet-vps",
-  "UTF-7",
-  "x-imap4-modified-utf7",
-  "UTF-16",
-  "UTF-16BE",
-  "UTF-16LE",
-  "T.61-8bit",
-  "x-user-defined",
-  "x-mac-arabic",
-  "x-mac-devanagari",
-  "x-mac-farsi",
-  "x-mac-gurmukhi",
-  "x-mac-gujarati",
-  "x-mac-hebrew",
-
-  "IBM850",
-  "IBM852",
-  "IBM855",
-  "IBM857",
-  "IBM862",
-  "IBM864",
-  "IBM866",
-  "Shift_JIS",
-  "ISO-2022-JP",
-  "EUC-JP",
-  "jis_0201",
-  "x-euc-tw",
-  "Big5",
-  "Big5-HKSCS",
-  "hkscs-1",
-  "EUC-KR",
-  "x-johab",
-  "GB2312",
-  "gbk",
-  "HZ-GB-2312",
-  "gb18030",
-  "replacement",
-];
-
-var decoderList = [
-  "ISO-8859-1",
-  "windows-1252",
-  "macintosh",
-  "UTF-8",
-  "us-ascii",
-  "ISO-8859-2",
-  "ISO-8859-3",
-  "ISO-8859-4",
-  "ISO-8859-5",
-  "ISO-8859-6",
-  "ISO-8859-6-I",
-  "ISO-8859-6-E",
-  "ISO-8859-7",
-  "ISO-8859-8",
-  "ISO-8859-8-I",
-  "ISO-8859-8-E",
-  "ISO-8859-9",
-  "ISO-8859-10",
-  "ISO-8859-13",
-  "ISO-8859-14",
-  "ISO-8859-15",
-  "ISO-8859-16",
-  "ISO-IR-111",
-  "windows-1250",
-  "windows-1251",
-  "windows-1253",
-  "windows-1254",
-  "windows-1255",
-  "windows-1256",
-  "windows-1257",
-  "windows-1258",
-  "TIS-620",
-  "windows-874",
-  "ISO-8859-11",
-  "KOI8-R",
-  "KOI8-U",
-  "x-mac-ce",
-  "x-mac-greek",
-  "x-mac-turkish",
-  "x-mac-croatian",
-  "x-mac-romanian",
-  "x-mac-cyrillic",
-  "x-mac-icelandic",
-  "armscii-8",
-  "x-viet-tcvn5712",
-  "VISCII",
-  "x-viet-vps",
-  "UTF-7",
-  "x-imap4-modified-utf7",
-  "UTF-16",
-  "UTF-16BE",
-  "UTF-16LE",
-  "T.61-8bit",
-  "x-user-defined",
-  "x-mac-arabic",
-  "x-mac-devanagari",
-  "x-mac-farsi",
-  "x-mac-gurmukhi",
-  "x-mac-gujarati",
-  "x-mac-hebrew",
-  "IBM850",
-  "IBM852",
-  "IBM855",
-  "IBM857",
-  "IBM862",
-  "IBM864",
-  "IBM866",
-  "Shift_JIS",
-  "ISO-2022-JP",
-  "EUC-JP",
-  "x-euc-tw",
-  "Big5",
-  "Big5-HKSCS",
-  "EUC-KR",
-  "x-johab",
-  "GB2312",
-  "gbk",
-  "HZ-GB-2312",
-  "gb18030",
-  "ISO-2022-KR",
-  "ISO-2022-CN",
-  "replacement",
-];
-
-function verifyList(aEnumerator, aList)
-{
-  var count = 0;
-
-  while (aEnumerator.hasMore()) {
-    var result = aEnumerator.getNext();
-    for (var i = 0; i < aList.length; i++) {
-      if (result == aList[i]) {
-        count++;
-        break;
-      }
-    }
-    if (i == aList.length) {
-      do_throw("Unknown chardet: " + result);
-    }
-  }
-  do_check_eq(count, aList.length);
-}
-
-function run_test()
-{
-  var cm = Components.classes["@mozilla.org/charset-converter-manager;1"]
-           .getService(Components.interfaces.nsICharsetConverterManager);
-
-  verifyList(cm.GetCharsetDetectorList(), detectList);
-  verifyList(cm.getEncoderList(), encoderList);
-  verifyList(cm.getDecoderList(), decoderList);
-}
--- a/mailnews/intl/test/unit/xpcshell.ini
+++ b/mailnews/intl/test/unit/xpcshell.ini
@@ -3,9 +3,8 @@ head =
 tail =
 support-files =
   CharsetConversionTests.js
 
 [test_decode_utf-7.js]
 [test_decode_utf-7_internal.js]
 [test_encode_utf-7.js]
 [test_encode_utf-7_internal.js]
-[test_bug718500.js]
--- a/mailnews/mime/src/jsmime.jsm
+++ b/mailnews/mime/src/jsmime.jsm
@@ -28,17 +28,20 @@ function FakeTextDecoder(label="UTF-8", 
   // us to use a C++-only class if we need better behavior.
 }
 FakeTextDecoder.prototype = {
   _reset: function (label) {
     this._encoder = Components.classes[
       "@mozilla.org/intl/scriptableunicodeconverter"]
       .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
     this._encoder.isInternal = true;
-    this._encoder.charset = label;
+    let manager = Components.classes[
+      "@mozilla.org/charset-converter-manager;1"]
+      .createInstance(Components.interfaces.nsICharsetConverterManager);
+    this._encoder.charset = manager.getCharsetAlias(label);
   },
   get encoding() { return this._encoder.charset; },
   decode: function (input, options = {}) {
     let more = 'stream' in options ? options.stream : false;
     let result = "";
     if (input !== undefined) {
       let data = new Uint8Array(input);
       result = this._encoder.convertFromByteArray(data, data.length);