Bug 862292 - Use UTF-8 for all outgoing email. r=mkmelin
--HG-- extra : amend_source : 74c7415aa16fbeecc4c01403747f0bef5c435549
This commit is contained in:
Родитель
5f5a728e3d
Коммит
b5a07fc993
|
@ -256,7 +256,6 @@ CalItipEmailTransport.prototype = {
|
|||
let composeFields = Cc["@mozilla.org/messengercompose/composefields;1"].createInstance(
|
||||
Ci.nsIMsgCompFields
|
||||
);
|
||||
composeFields.characterSet = "UTF-8";
|
||||
composeFields.to = toList;
|
||||
let mailfrom = identity.fullName.length
|
||||
? identity.fullName + " <" + identity.email + ">"
|
||||
|
|
|
@ -95,7 +95,6 @@ function sendViaEmail() {
|
|||
// In general we can have non-ASCII characters, and compose's charset
|
||||
// detection doesn't seem to work when the HTML part is pure ASCII but the
|
||||
// text isn't. So take the easy way out and force UTF-8.
|
||||
fields.characterSet = "UTF-8";
|
||||
fields.bodyIsAsciiOnly = false;
|
||||
params.composeFields = fields;
|
||||
|
||||
|
|
|
@ -147,7 +147,6 @@ var gEncryptedURIService = Cc[
|
|||
].getService(Ci.nsIEncryptedSMIMEURIsService);
|
||||
|
||||
// i18n globals
|
||||
var gCharsetConvertManager;
|
||||
var _gComposeBundle;
|
||||
function getComposeBundle() {
|
||||
// That one has to be lazy. Getting a reference to an element with a XBL
|
||||
|
@ -219,9 +218,6 @@ function InitializeGlobalVariables() {
|
|||
gCloseWindowAfterSave = false;
|
||||
gSavedSendNowKey = null;
|
||||
gSendFormat = Ci.nsIMsgCompSendFormat.AskUser;
|
||||
gCharsetConvertManager = Cc[
|
||||
"@mozilla.org/charset-converter-manager;1"
|
||||
].getService(Ci.nsICharsetConverterManager);
|
||||
gManualAttachmentReminder = false;
|
||||
gDisableAttachmentReminder = false;
|
||||
gLanguageObserver = null;
|
||||
|
@ -245,7 +241,6 @@ InitializeGlobalVariables();
|
|||
|
||||
function ReleaseGlobalVariables() {
|
||||
gCurrentIdentity = null;
|
||||
gCharsetConvertManager = null;
|
||||
gMsgCompose = null;
|
||||
gOriginalMsgURI = null;
|
||||
gMessenger = null;
|
||||
|
@ -2660,17 +2655,6 @@ function GetArgs(originalData) {
|
|||
}
|
||||
|
||||
function ComposeFieldsReady() {
|
||||
// Limit the charsets to those we think are safe to encode (i.e., they are in
|
||||
// the charset menu). Easiest way to normalize this is to use the TextDecoder
|
||||
// to get the canonical alias and default if it isn't valid.
|
||||
let charset;
|
||||
try {
|
||||
charset = new TextDecoder(gMsgCompose.compFields.characterSet).encoding;
|
||||
} catch (e) {
|
||||
charset = gMsgCompose.compFields.defaultCharacterSet;
|
||||
}
|
||||
SetDocumentCharacterSet(charset);
|
||||
|
||||
// If we are in plain text, we need to set the wrap column
|
||||
if (!gMsgCompose.composeHTML) {
|
||||
try {
|
||||
|
@ -4111,19 +4095,6 @@ var SecurityController = {
|
|||
},
|
||||
};
|
||||
|
||||
function SetDocumentCharacterSet(aCharset) {
|
||||
if (gMsgCompose) {
|
||||
// Replace generic Japanese with ISO-2022-JP.
|
||||
if (aCharset == "Japanese") {
|
||||
aCharset = "ISO-2022-JP";
|
||||
}
|
||||
gMsgCompose.SetDocumentCharset(aCharset);
|
||||
updateEncodingInStatusBar();
|
||||
} else {
|
||||
dump("Compose has not been created!\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the translatable string of every recipient row
|
||||
* with the properly formatted values.
|
||||
|
@ -4207,37 +4178,6 @@ function createRecipientLabel(labelID) {
|
|||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the full display string for any non-default text encoding of the
|
||||
* current composition (friendly name plus official character set name).
|
||||
* For the default text encoding, return empty string (""), to reduce
|
||||
* ux-complexity, e.g. for the default Status Bar display.
|
||||
* Note: The default is retrieved from mailnews.send_default_charset.
|
||||
*
|
||||
* @return string representation of non-default charset, otherwise "".
|
||||
*/
|
||||
function GetCharsetUIString() {
|
||||
// The charset here is already the canonical charset (not an alias).
|
||||
let charset = gMsgCompose.compFields.characterSet;
|
||||
if (!charset) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (
|
||||
charset.toLowerCase() !=
|
||||
gMsgCompose.compFields.defaultCharacterSet.toLowerCase()
|
||||
) {
|
||||
try {
|
||||
return gCharsetConvertManager.getCharsetTitle(charset);
|
||||
} catch (e) {
|
||||
// Not a canonical charset after all...
|
||||
Cu.reportError("No charset title for charset=" + charset);
|
||||
return charset;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function onSendSMIME() {
|
||||
let emailAddresses = [];
|
||||
|
||||
|
@ -4594,43 +4534,6 @@ function CompleteGenericSendMessage(msgType) {
|
|||
// hook for extra compose pre-processing
|
||||
Services.obs.notifyObservers(window, "mail:composeOnSend");
|
||||
|
||||
var originalCharset = gMsgCompose.compFields.characterSet;
|
||||
// Check if the headers of composing mail can be converted to a mail charset.
|
||||
if (
|
||||
msgType == Ci.nsIMsgCompDeliverMode.Now ||
|
||||
msgType == Ci.nsIMsgCompDeliverMode.Later ||
|
||||
msgType == Ci.nsIMsgCompDeliverMode.Background ||
|
||||
msgType == Ci.nsIMsgCompDeliverMode.Save ||
|
||||
msgType == Ci.nsIMsgCompDeliverMode.SaveAsDraft ||
|
||||
msgType == Ci.nsIMsgCompDeliverMode.AutoSaveAsDraft ||
|
||||
msgType == Ci.nsIMsgCompDeliverMode.SaveAsTemplate
|
||||
) {
|
||||
var fallbackCharset = {};
|
||||
// Check encoding, switch to UTF-8 if the default encoding doesn't fit
|
||||
// and disable_fallback_to_utf8 isn't set for this encoding.
|
||||
if (
|
||||
!gMsgCompose.checkCharsetConversion(getCurrentIdentity(), fallbackCharset)
|
||||
) {
|
||||
let disableFallback = Services.prefs.getBoolPref(
|
||||
"mailnews.disable_fallback_to_utf8." + originalCharset,
|
||||
false
|
||||
);
|
||||
if (disableFallback) {
|
||||
gMsgCompose.compFields.needToCheckCharset = false;
|
||||
} else {
|
||||
fallbackCharset.value = "UTF-8";
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
fallbackCharset &&
|
||||
fallbackCharset.value &&
|
||||
fallbackCharset.value != ""
|
||||
) {
|
||||
gMsgCompose.SetDocumentCharset(fallbackCharset.value);
|
||||
}
|
||||
}
|
||||
|
||||
if (!gSelectedTechnologyIsPGP) {
|
||||
gMsgCompose.compFields.composeSecure.requireEncryptMessage = gSendEncrypted;
|
||||
gMsgCompose.compFields.composeSecure.signMessage = gSendSigned;
|
||||
|
@ -4691,9 +4594,6 @@ function CompleteGenericSendMessage(msgType) {
|
|||
Cu.reportError("GenericSendMessage FAILED: " + ex);
|
||||
ToggleWindowLock(false);
|
||||
}
|
||||
if (gMsgCompose && originalCharset != gMsgCompose.compFields.characterSet) {
|
||||
SetDocumentCharacterSet(gMsgCompose.compFields.characterSet);
|
||||
}
|
||||
|
||||
if (
|
||||
msgType == Ci.nsIMsgCompDeliverMode.Now ||
|
||||
|
@ -5371,17 +5271,6 @@ function updateLanguageInStatusBar() {
|
|||
}
|
||||
}
|
||||
|
||||
function updateEncodingInStatusBar() {
|
||||
let encodingUIString = GetCharsetUIString();
|
||||
let encodingStatusPanel = document.getElementById("encodingStatusPanel");
|
||||
if (!encodingStatusPanel) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update status display; no status display for default text encoding.
|
||||
encodingStatusPanel.collapsed = !(encodingStatusPanel.value = encodingUIString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Return Receipt (Disposition-Notification-To: header).
|
||||
*
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
%messengercomposeDTD;
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
<!ENTITY % charsetDTD SYSTEM "chrome://global/locale/charsetMenu.dtd" >
|
||||
%charsetDTD;
|
||||
<!ENTITY % customizeToolbarDTD SYSTEM "chrome://messenger/locale/customizeToolbar.dtd">
|
||||
%customizeToolbarDTD;
|
||||
<!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd">
|
||||
|
@ -1716,7 +1714,8 @@
|
|||
accesskey="&enableInlineSpellChecker.accesskey;" checked="false"
|
||||
type="checkbox"
|
||||
oncommand="enableInlineSpellCheck(!gSpellChecker.enabled);"/>
|
||||
<menuitem label=""eCmd.label;"
|
||||
<menuitem id="menu_quoteMessage"
|
||||
label=""eCmd.label;"
|
||||
accesskey=""eCmd.accesskey;"
|
||||
command="cmd_quoteMessage"/>
|
||||
<menuseparator/>
|
||||
|
@ -1727,13 +1726,6 @@
|
|||
command="cmd_toggleReturnReceipt"/>
|
||||
<menuitem id="dsnMenu" type="checkbox" label="&dsnMenu.label;" accesskey="&dsnMenu.accesskey;" oncommand="ToggleDSN(event.target)"/>
|
||||
<menuseparator/>
|
||||
<menu id="charsetMenu"
|
||||
data-l10n-id="menu-view-charset"
|
||||
oncommand="SetDocumentCharacterSet(event.target.getAttribute('charset'));"
|
||||
onpopupshowing="UpdateCharsetMenu(gMsgCompose.compFields.characterSet, this);">
|
||||
<menupopup id="charsetPopup" detectors="false"
|
||||
onpopupshowing="CharsetMenu.build(this, true, this.getAttribute('detectors') != 'false');"/>
|
||||
</menu>
|
||||
<menu id="outputFormatMenu" label="&deliveryFormatMenu.label;" accesskey="&deliveryFormatMenu.accesskey;" oncommand="OutputFormatMenuSelect(event.target)">
|
||||
<menupopup id="outputFormatMenuPopup">
|
||||
<menuitem type="radio" name="output_format" label="&autoFormatCmd.label;" accesskey="&autoFormatCmd.accesskey;" id="format_auto"/>
|
||||
|
@ -2578,7 +2570,6 @@
|
|||
oncommand="showMessageComposeSecurityStatus();">
|
||||
<image/>
|
||||
</hbox>
|
||||
<label id="encodingStatusPanel" class="statusbarpanel" tooltiptext="&encodingStatusPanel.tooltip;"/>
|
||||
<hbox id="spellCheckStatusPanel" class="statusbarpanel">
|
||||
<toolbarbutton id="languageStatusButton"
|
||||
tooltiptext="&languageStatusButton.tooltip;"
|
||||
|
|
|
@ -25,9 +25,7 @@ Preferences.addAll([
|
|||
{ id: "font.language.group", type: "wstring" },
|
||||
{ id: "browser.display.use_document_fonts", type: "int" },
|
||||
{ id: "mail.fixed_width_messages", type: "bool" },
|
||||
{ id: "mailnews.send_default_charset", type: "wstring" },
|
||||
{ id: "mailnews.view_default_charset", type: "wstring" },
|
||||
{ id: "mailnews.reply_in_default_charset", type: "bool" },
|
||||
]);
|
||||
|
||||
var gFontsDialog = {
|
||||
|
@ -198,16 +196,10 @@ var gFontsDialog = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Both mailnews.send_default_charset and mailnews.view_default_charset
|
||||
* are nsIPrefLocalizedString. Its default value is different depending
|
||||
* on the user locale (see bug 48842).
|
||||
* mailnews.view_default_charset is nsIPrefLocalizedString. Its default value
|
||||
* is different depending on the user locale (see bug 48842).
|
||||
*/
|
||||
ondialogaccept() {
|
||||
var sendCharsetStr = Services.prefs.getComplexValue(
|
||||
"mailnews.send_default_charset",
|
||||
Ci.nsIPrefLocalizedString
|
||||
).data;
|
||||
|
||||
var viewCharsetStr = Services.prefs.getComplexValue(
|
||||
"mailnews.view_default_charset",
|
||||
Ci.nsIPrefLocalizedString
|
||||
|
@ -217,16 +209,6 @@ var gFontsDialog = {
|
|||
|
||||
// Here we compare preference's stored value with default one and,
|
||||
// if needed, show it as "default" on Config Editor instead of "user set".
|
||||
if (
|
||||
sendCharsetStr ===
|
||||
defaultPrefs.getComplexValue(
|
||||
"send_default_charset",
|
||||
Ci.nsIPrefLocalizedString
|
||||
).data
|
||||
) {
|
||||
Services.prefs.clearUserPref("mailnews.send_default_charset");
|
||||
}
|
||||
|
||||
if (
|
||||
viewCharsetStr ===
|
||||
defaultPrefs.getComplexValue(
|
||||
|
|
|
@ -262,28 +262,16 @@
|
|||
<separator class="thin"/>
|
||||
<hbox>
|
||||
<vbox pack="end">
|
||||
<hbox align="center" flex="1" class="indent">
|
||||
<label control="sendDefaultCharsetList"
|
||||
data-l10n-id="font-outgoing-email-label"/>
|
||||
</hbox>
|
||||
<hbox align="center" flex="1" class="indent">
|
||||
<label control="viewDefaultCharsetList"
|
||||
data-l10n-id="font-incoming-email-label"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<menulist is="menulist-charsetpicker-sending" id="sendDefaultCharsetList"
|
||||
preference="mailnews.send_default_charset"/>
|
||||
<menulist is="menulist-charsetpicker-viewing" id="viewDefaultCharsetList"
|
||||
preference="mailnews.view_default_charset"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
|
||||
<separator class="thin"/>
|
||||
|
||||
<checkbox id="replyInDefaultCharset"
|
||||
data-l10n-id="default-font-reply-checkbox"
|
||||
preference="mailnews.reply_in_default_charset"/>
|
||||
</html:fieldset>
|
||||
</html:div>
|
||||
<separator/>
|
||||
|
|
|
@ -689,7 +689,6 @@ var EnigmailAutocrypt = {
|
|||
return new Promise((resolve, reject) => {
|
||||
self.createSetupMessage(identity).then(res => {
|
||||
let composeFields = Cc["@mozilla.org/messengercompose/composefields;1"].createInstance(Ci.nsIMsgCompFields);
|
||||
composeFields.characterSet = "UTF-8";
|
||||
composeFields.messageId = EnigmailRNG.generateRandomString(27) + "-enigmail";
|
||||
composeFields.from = identity.email;
|
||||
composeFields.to = identity.email;
|
||||
|
|
|
@ -2808,19 +2808,6 @@ Enigmail.msg = {
|
|||
// Encode ciphertext from unicode to charset
|
||||
var cipherText = EnigmailData.convertFromUnicode(pgpBlock, charset);
|
||||
|
||||
if (
|
||||
!this.getMailPref("mailnews.reply_in_default_charset") &&
|
||||
blockType == "MESSAGE"
|
||||
) {
|
||||
// set charset according to PGP block, if available (encrypted messages only)
|
||||
let armorHeaders = EnigmailArmor.getArmorHeaders(cipherText);
|
||||
|
||||
if ("charset" in armorHeaders) {
|
||||
charset = armorHeaders.charset;
|
||||
gMsgCompose.SetDocumentCharset(charset);
|
||||
}
|
||||
}
|
||||
|
||||
// Decrypt message
|
||||
var signatureObj = {};
|
||||
signatureObj.value = "";
|
||||
|
|
|
@ -270,7 +270,6 @@ tag=Tags
|
|||
andOthers=et al.
|
||||
|
||||
# mailnews.js
|
||||
mailnews.send_default_charset=UTF-8
|
||||
mailnews.view_default_charset=ISO-8859-1
|
||||
|
||||
# whether to generate display names in last first order
|
||||
|
|
|
@ -50,7 +50,6 @@ support-files = data/**
|
|||
[browser_base64Display.js]
|
||||
[browser_blockedContent.js]
|
||||
[browser_charsetEdit.js]
|
||||
[browser_charsetUpgrade.js]
|
||||
[browser_contactsSidebar.js]
|
||||
skip-if = os == 'win' && bits == 64 && debug # Bug 1626818
|
||||
[browser_cp932Display.js]
|
||||
|
@ -70,6 +69,7 @@ reason = See bug 1413851.
|
|||
[browser_imageInsertionDialog.js]
|
||||
[browser_multipartRelated.js]
|
||||
[browser_newmsgComposeIdentity.js]
|
||||
[browser_quoteMessage.js]
|
||||
[browser_replyAddresses.js]
|
||||
skip-if = debug # Bug 1601591
|
||||
[browser_replyCatchAll.js]
|
||||
|
|
|
@ -51,18 +51,6 @@ var gDrafts;
|
|||
|
||||
add_task(function setupModule(module) {
|
||||
gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
|
||||
|
||||
// Ensure reply charset isn't UTF-8, otherwise there's no need to upgrade,
|
||||
// which is what this test tests.
|
||||
let str = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
|
||||
Ci.nsIPrefLocalizedString
|
||||
);
|
||||
str.data = "windows-1252";
|
||||
Services.prefs.setComplexValue(
|
||||
"mailnews.send_default_charset",
|
||||
Ci.nsIPrefLocalizedString,
|
||||
str
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -106,8 +94,7 @@ function getMsgHeaders(aMsgHdr, aGetText = false) {
|
|||
|
||||
/**
|
||||
* Test that if we reply to a message in an invalid charset, we don't try to compose
|
||||
* in that charset. Instead, we should be using the default charset (set to
|
||||
* not be UTF-8 in this test).
|
||||
* in that charset. Instead, we should be using UTF-8.
|
||||
*/
|
||||
add_task(function test_wrong_reply_charset() {
|
||||
let folder = gDrafts;
|
||||
|
@ -128,10 +115,10 @@ add_task(function test_wrong_reply_charset() {
|
|||
close_compose_window(rwc);
|
||||
|
||||
let draftMsg = select_click_row(1);
|
||||
Assert.equal(getMsgHeaders(draftMsg).get("").charset, "windows-1252");
|
||||
Assert.equal(getMsgHeaders(draftMsg).get("").charset, "UTF-8");
|
||||
press_delete(mc); // Delete message
|
||||
|
||||
// Edit the original message. Charset should be windows-1252 now.
|
||||
// Edit the original message. Charset should be UTF-8 now.
|
||||
msg = select_click_row(0);
|
||||
|
||||
// Wait for the notification with the Edit button.
|
||||
|
@ -145,7 +132,7 @@ add_task(function test_wrong_reply_charset() {
|
|||
rwc.keypress(null, "s", { shiftKey: false, accelKey: true });
|
||||
close_compose_window(rwc);
|
||||
msg = select_click_row(0);
|
||||
Assert.equal(getMsgHeaders(msg).get("").charset, "windows-1252");
|
||||
Assert.equal(getMsgHeaders(msg).get("").charset, "UTF-8");
|
||||
press_delete(mc); // Delete message
|
||||
});
|
||||
|
||||
|
@ -218,7 +205,3 @@ add_task(function test_no_mojibake() {
|
|||
);
|
||||
press_delete(mc); // Delete message
|
||||
});
|
||||
|
||||
registerCleanupFunction(function teardownModule(module) {
|
||||
Services.prefs.clearUserPref("mailnews.send_default_charset");
|
||||
});
|
||||
|
|
|
@ -1,249 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* Tests that we do the right thing wrt. message encoding, especially when
|
||||
* all characters doesn't fit the selected charset.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var {
|
||||
get_msg_source,
|
||||
open_compose_new_mail,
|
||||
setup_msg_contents,
|
||||
type_in_composer,
|
||||
} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
|
||||
var {
|
||||
be_in_folder,
|
||||
get_special_folder,
|
||||
press_delete,
|
||||
select_click_row,
|
||||
} = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
|
||||
);
|
||||
var { plan_for_window_close, wait_for_window_close } = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/WindowHelpers.jsm"
|
||||
);
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
|
||||
var gDrafts;
|
||||
var gOutbox;
|
||||
|
||||
add_task(function setupModule(module) {
|
||||
gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
|
||||
gOutbox = get_special_folder(Ci.nsMsgFolderFlags.Queue);
|
||||
|
||||
// Ensure reply charset isn't UTF-8, otherwise there's no need to upgrade,
|
||||
// which is what this test tests.
|
||||
let str = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
|
||||
Ci.nsIPrefLocalizedString
|
||||
);
|
||||
str.data = "windows-1252";
|
||||
Services.prefs.setComplexValue(
|
||||
"mailnews.send_default_charset",
|
||||
Ci.nsIPrefLocalizedString,
|
||||
str
|
||||
);
|
||||
|
||||
// Don't create paragraphs in the test.
|
||||
// When creating a paragraph, the test fails to retrieve the
|
||||
// original character set windows-1252. Until we understand why,
|
||||
// we run without paragraphs.
|
||||
Services.prefs.setBoolPref("mail.compose.default_to_paragraph", false);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that if all characters don't fit the current charset selection,
|
||||
* we upgrade properly to UTF-8. In HTML composition.
|
||||
*/
|
||||
add_task(function test_encoding_upgrade_html_compose() {
|
||||
Services.prefs.setBoolPref("mail.identity.default.compose_html", true);
|
||||
let compWin = open_compose_new_mail();
|
||||
|
||||
setup_msg_contents(
|
||||
compWin,
|
||||
"someone@example.com",
|
||||
"encoding upgrade test - html mode",
|
||||
"so far, this is latin1\n"
|
||||
);
|
||||
|
||||
// Ctrl+S = save as draft.
|
||||
compWin.keypress(null, "s", { shiftKey: false, accelKey: true });
|
||||
|
||||
be_in_folder(gDrafts);
|
||||
let draftMsg = select_click_row(0);
|
||||
|
||||
// Charset should still be the default.
|
||||
Assert.equal(draftMsg.Charset, "windows-1252");
|
||||
|
||||
// We could pass "windows-1252", but the message is ASCII.
|
||||
let draftMsgContent = get_msg_source(draftMsg);
|
||||
if (!draftMsgContent.includes('content="text/html; charset=windows-1252"')) {
|
||||
throw new Error(
|
||||
"Expected content type not in msg; draftMsgContent=" + draftMsgContent
|
||||
);
|
||||
}
|
||||
|
||||
const CHINESE = "漢皇重色思傾國漢皇重色思傾國";
|
||||
type_in_composer(compWin, [
|
||||
"but now, we enter some chinese: " + CHINESE + "\n",
|
||||
]);
|
||||
|
||||
// Ctrl+U = Underline (so we can check multipart/alternative gets right,
|
||||
// without it html->plaintext conversion will it as send plain text only)
|
||||
compWin.keypress(null, "U", { shiftKey: false, accelKey: true });
|
||||
|
||||
type_in_composer(compWin, ["content need to be upgraded to utf-8 now."]);
|
||||
|
||||
// Ctrl+S = save as draft.
|
||||
compWin.keypress(null, "s", { shiftKey: false, accelKey: true });
|
||||
|
||||
be_in_folder(gDrafts);
|
||||
let draftMsg2 = select_click_row(0);
|
||||
// Charset should have be upgraded to UTF-8.
|
||||
Assert.equal(draftMsg2.Charset, "UTF-8");
|
||||
|
||||
let draftMsg2Content = get_msg_source(draftMsg2, "UTF-8");
|
||||
if (!draftMsg2Content.includes('content="text/html; charset=UTF-8"')) {
|
||||
throw new Error(
|
||||
"Expected content type not in msg; draftMsg2Content=" + draftMsg2Content
|
||||
);
|
||||
}
|
||||
|
||||
if (!draftMsg2Content.includes(CHINESE)) {
|
||||
throw new Error(
|
||||
"Chinese text not in msg; CHINESE=" +
|
||||
CHINESE +
|
||||
", draftMsg2Content=" +
|
||||
draftMsg2Content
|
||||
);
|
||||
}
|
||||
|
||||
plan_for_window_close(compWin);
|
||||
compWin.window.goDoCommand("cmd_sendLater");
|
||||
wait_for_window_close();
|
||||
|
||||
be_in_folder(gOutbox);
|
||||
let outMsg = select_click_row(0);
|
||||
let outMsgContent = get_msg_source(outMsg, "UTF-8");
|
||||
|
||||
// This message should be multipart/alternative.
|
||||
if (!outMsgContent.includes("Content-Type: multipart/alternative")) {
|
||||
throw new Error("Expected multipart/alternative; content=" + outMsgContent);
|
||||
}
|
||||
|
||||
let chinesePlainIdx = outMsgContent.indexOf(CHINESE);
|
||||
Assert.ok(
|
||||
chinesePlainIdx > 0,
|
||||
"chinesePlainIdx=" + chinesePlainIdx + ", outMsgContent=" + outMsgContent
|
||||
);
|
||||
|
||||
let chineseHTMLIdx = outMsgContent.indexOf(CHINESE, chinesePlainIdx);
|
||||
Assert.ok(
|
||||
chineseHTMLIdx > 0,
|
||||
"chineseHTMLIdx=" + chineseHTMLIdx + ", outMsgContent=" + outMsgContent
|
||||
);
|
||||
|
||||
// Make sure the actual html also got the content type set correctly.
|
||||
if (!outMsgContent.includes('content="text/html; charset=UTF-8"')) {
|
||||
throw new Error(
|
||||
"Expected content type not in html; outMsgContent=" + outMsgContent
|
||||
);
|
||||
}
|
||||
|
||||
press_delete(); // Delete the msg from Outbox.
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that if all characters don't fit the current charset selection,
|
||||
* we upgrade properly to UTF-8. In plaintext composition.
|
||||
*/
|
||||
add_task(function test_encoding_upgrade_plaintext_compose() {
|
||||
Services.prefs.setBoolPref("mail.identity.default.compose_html", false);
|
||||
let compWin = open_compose_new_mail();
|
||||
Services.prefs.setBoolPref("mail.identity.default.compose_html", true);
|
||||
|
||||
setup_msg_contents(
|
||||
compWin,
|
||||
"someone-else@example.com",
|
||||
"encoding upgrade test - plaintext",
|
||||
"this is plaintext latin1\n"
|
||||
);
|
||||
|
||||
// Ctrl+S = Save as Draft.
|
||||
compWin.keypress(null, "s", { shiftKey: false, accelKey: true });
|
||||
|
||||
be_in_folder(gDrafts);
|
||||
let draftMsg = select_click_row(0);
|
||||
|
||||
// Charset should still be the default.
|
||||
Assert.equal(draftMsg.Charset, "windows-1252");
|
||||
|
||||
const CHINESE = "漢皇重色思傾國漢皇重色思傾國";
|
||||
type_in_composer(compWin, [
|
||||
"enter some plain text chinese: " + CHINESE,
|
||||
"content need to be upgraded to utf-8 now.",
|
||||
]);
|
||||
|
||||
// Ctrl+S = Save as Draft.
|
||||
compWin.keypress(null, "s", { shiftKey: false, accelKey: true });
|
||||
|
||||
be_in_folder(gDrafts);
|
||||
let draftMsg2 = select_click_row(0);
|
||||
// Charset should have be upgraded to UTF-8.
|
||||
Assert.equal(draftMsg2.Charset, "UTF-8");
|
||||
|
||||
let draftMsg2Content = get_msg_source(draftMsg2, "UTF-8");
|
||||
if (draftMsg2Content.includes("<html>")) {
|
||||
throw new Error(
|
||||
"Plaintext draft contained <html>; " +
|
||||
"draftMsg2Content=" +
|
||||
draftMsg2Content
|
||||
);
|
||||
}
|
||||
|
||||
if (!draftMsg2Content.includes(CHINESE)) {
|
||||
throw new Error(
|
||||
"Chinese text not in msg; CHINESE=" +
|
||||
CHINESE +
|
||||
", draftMsg2Content=" +
|
||||
draftMsg2Content
|
||||
);
|
||||
}
|
||||
|
||||
plan_for_window_close(compWin);
|
||||
compWin.window.goDoCommand("cmd_sendLater");
|
||||
wait_for_window_close();
|
||||
|
||||
be_in_folder(gOutbox);
|
||||
let outMsg = select_click_row(0);
|
||||
let outMsgContent = get_msg_source(outMsg, "UTF-8");
|
||||
|
||||
// This message should be text/plain;
|
||||
if (!outMsgContent.includes("Content-Type: text/plain")) {
|
||||
throw new Error("Expected text/plain; content=" + outMsgContent);
|
||||
}
|
||||
|
||||
if (!outMsgContent.includes(CHINESE)) {
|
||||
throw new Error(
|
||||
"Chinese text not in msg; CHINESE=" +
|
||||
CHINESE +
|
||||
", outMsgContent=" +
|
||||
outMsgContent
|
||||
);
|
||||
}
|
||||
|
||||
press_delete(); // Delete the msg from Outbox.
|
||||
});
|
||||
|
||||
registerCleanupFunction(function teardownModule(module) {
|
||||
Services.prefs.clearUserPref("mailnews.send_default_charset");
|
||||
Services.prefs.clearUserPref("mail.compose.default_to_paragraph");
|
||||
Services.prefs.clearUserPref("mail.identity.default.compose_html");
|
||||
});
|
|
@ -0,0 +1,84 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* Tests that in the compose window, Options > Quote Message works well for
|
||||
* non-UTF8 encoding.
|
||||
*/
|
||||
|
||||
var {
|
||||
close_compose_window,
|
||||
open_compose_with_edit_as_new,
|
||||
open_compose_with_forward,
|
||||
open_compose_with_forward_as_attachments,
|
||||
open_compose_with_reply,
|
||||
get_compose_body,
|
||||
get_msg_source,
|
||||
} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
|
||||
var {
|
||||
assert_selected_and_displayed,
|
||||
be_in_folder,
|
||||
create_folder,
|
||||
mc,
|
||||
open_message_from_file,
|
||||
press_delete,
|
||||
select_click_row,
|
||||
get_special_folder,
|
||||
} = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
|
||||
);
|
||||
var { close_window } = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/WindowHelpers.jsm"
|
||||
);
|
||||
var elib = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/elementslib.jsm"
|
||||
);
|
||||
|
||||
var gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
|
||||
|
||||
var folderToStoreMessages;
|
||||
|
||||
add_task(function setupModule(module) {
|
||||
folderToStoreMessages = create_folder("QuoteTestFolder");
|
||||
});
|
||||
|
||||
add_task(async function test_quoteMessage() {
|
||||
be_in_folder(folderToStoreMessages);
|
||||
|
||||
let file = new FileUtils.File(getTestFilePath("data/iso-2022-jp.eml"));
|
||||
let msgc = await open_message_from_file(file);
|
||||
// Copy the message to a folder, so that Quote Message menu item is enabled.
|
||||
let documentChild = msgc.e("messagepane").contentDocument.firstChild;
|
||||
msgc.rightClick(new elib.Elem(documentChild));
|
||||
msgc.click_menus_in_sequence(msgc.e("mailContext"), [
|
||||
{ id: "mailContext-copyMenu" },
|
||||
{ label: "Local Folders" },
|
||||
{ label: "QuoteTestFolder" },
|
||||
]);
|
||||
close_window(msgc);
|
||||
|
||||
// Select message and click reply.
|
||||
select_click_row(0);
|
||||
let cwc = open_compose_with_reply();
|
||||
let composeBody = get_compose_body(cwc).textContent;
|
||||
Assert.equal(
|
||||
composeBody.match(/世界/g).length,
|
||||
1,
|
||||
"Message should be quoted by replying"
|
||||
);
|
||||
|
||||
// Click Options > Quote Message.
|
||||
cwc.click(cwc.eid("optionsMenu"));
|
||||
cwc.click_menus_in_sequence(cwc.e("optionsMenuPopup"), [
|
||||
{ id: "menu_quoteMessage" },
|
||||
]);
|
||||
composeBody = get_compose_body(cwc).textContent;
|
||||
Assert.equal(
|
||||
composeBody.match(/世界/g).length,
|
||||
2,
|
||||
"Message should be quoted again by Options > Quote Message."
|
||||
);
|
||||
|
||||
close_compose_window(cwc);
|
||||
});
|
|
@ -16,8 +16,6 @@
|
|||
* Bug 1323377:
|
||||
* Tests that the correct charset is used, even if the message
|
||||
* wasn't viewed before answering/forwarding.
|
||||
* For good measure some tests are included for charset overriding
|
||||
* and enforcing the charset default.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
@ -61,8 +59,6 @@ add_task(function setupModule(module) {
|
|||
async function subtest_replyEditAsNewForward_charset(
|
||||
aAction,
|
||||
aFile,
|
||||
aCharset,
|
||||
aOverride = null,
|
||||
aViewed = true
|
||||
) {
|
||||
be_in_folder(folderToStoreMessages);
|
||||
|
@ -89,14 +85,6 @@ async function subtest_replyEditAsNewForward_charset(
|
|||
assert_selected_and_displayed(mc, msg);
|
||||
}
|
||||
|
||||
if (aOverride) {
|
||||
// Display the message using the override charset.
|
||||
// Use the app menu which is also available on Mac.
|
||||
mc.click_through_appmenu([{ label: "View" }, { label: "Text Encoding" }], {
|
||||
label: aOverride,
|
||||
});
|
||||
}
|
||||
|
||||
let fwdWin;
|
||||
switch (aAction) {
|
||||
case 1: // Reply.
|
||||
|
@ -115,7 +103,7 @@ async function subtest_replyEditAsNewForward_charset(
|
|||
|
||||
// Check the charset in the compose window.
|
||||
let charset = fwdWin.e("content-frame").contentDocument.charset;
|
||||
Assert.equal(charset, aCharset, "Compose window has the wrong charset");
|
||||
Assert.equal(charset, "UTF-8", "Compose window has the wrong charset");
|
||||
close_compose_window(fwdWin);
|
||||
|
||||
press_delete(mc);
|
||||
|
@ -123,27 +111,11 @@ async function subtest_replyEditAsNewForward_charset(
|
|||
|
||||
add_task(async function test_replyEditAsNewForward_charsetFromBody() {
|
||||
// Check that the charset is taken from the message body (bug 1026989).
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
1,
|
||||
"./multipart-charset.eml",
|
||||
"EUC-KR"
|
||||
);
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
2,
|
||||
"./multipart-charset.eml",
|
||||
"EUC-KR"
|
||||
);
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
3,
|
||||
"./multipart-charset.eml",
|
||||
"EUC-KR"
|
||||
);
|
||||
await subtest_replyEditAsNewForward_charset(1, "./multipart-charset.eml");
|
||||
await subtest_replyEditAsNewForward_charset(2, "./multipart-charset.eml");
|
||||
await subtest_replyEditAsNewForward_charset(3, "./multipart-charset.eml");
|
||||
// For "forward as attachment" we use the default charset (which is UTF-8).
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
4,
|
||||
"./multipart-charset.eml",
|
||||
"UTF-8"
|
||||
);
|
||||
await subtest_replyEditAsNewForward_charset(4, "./multipart-charset.eml");
|
||||
});
|
||||
|
||||
add_task(async function test_reply_noUTF16() {
|
||||
|
@ -151,76 +123,17 @@ add_task(async function test_reply_noUTF16() {
|
|||
await subtest_replyEditAsNewForward_charset(1, "./body-utf16.eml", "UTF-8");
|
||||
});
|
||||
|
||||
add_task(async function test_replyEditAsNewForward_override() {
|
||||
// Check that the override is honoured (inspired by bug 1323377).
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
1,
|
||||
"./multipart-charset.eml",
|
||||
"UTF-8",
|
||||
"Unicode"
|
||||
);
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
2,
|
||||
"./multipart-charset.eml",
|
||||
"windows-1252",
|
||||
"Western"
|
||||
);
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
3,
|
||||
"./multipart-charset.eml",
|
||||
"ISO-8859-7",
|
||||
"Greek (ISO)"
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_replyEditAsNewForward_enforceDefault() {
|
||||
// Check that the default is honoured (inspired by bug 1323377).
|
||||
Services.prefs.setBoolPref("mailnews.reply_in_default_charset", true);
|
||||
Services.prefs.setCharPref("mailnews.send_default_charset", "ISO-8859-7");
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
1,
|
||||
"./multipart-charset.eml",
|
||||
"ISO-8859-7"
|
||||
);
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
2,
|
||||
"./multipart-charset.eml",
|
||||
"ISO-8859-7"
|
||||
);
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
3,
|
||||
"./multipart-charset.eml",
|
||||
"ISO-8859-7"
|
||||
);
|
||||
Services.prefs.clearUserPref("mailnews.reply_in_default_charset");
|
||||
Services.prefs.clearUserPref("mailnews.send_default_charset");
|
||||
});
|
||||
|
||||
add_task(async function test_replyEditAsNewForward_noPreview() {
|
||||
// Check that it works even if the message wasn't viewed before, so
|
||||
// switch off the preview pane (bug 1323377).
|
||||
be_in_folder(folderToStoreMessages);
|
||||
mc.window.goDoCommand("cmd_toggleMessagePane");
|
||||
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
1,
|
||||
"./format-flowed.eml",
|
||||
"windows-1252",
|
||||
null,
|
||||
false
|
||||
);
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
2,
|
||||
"./body-greek.eml",
|
||||
"ISO-8859-7",
|
||||
null,
|
||||
false
|
||||
);
|
||||
await subtest_replyEditAsNewForward_charset(1, "./format-flowed.eml", false);
|
||||
await subtest_replyEditAsNewForward_charset(2, "./body-greek.eml", false);
|
||||
await subtest_replyEditAsNewForward_charset(
|
||||
3,
|
||||
"./multipart-charset.eml",
|
||||
"EUC-KR",
|
||||
null,
|
||||
false
|
||||
);
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
To: test1@test.invalid
|
||||
From: test2@test.invalid
|
||||
Subject: test quote ISO-2022-JP encoded message
|
||||
Date: Mon, 17 Aug 2020 10:10:47 +0900
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=ISO-2022-JP; format=flowed; delsp=yes
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Language: en-US
|
||||
|
||||
hello
|
||||
|
||||
$B@$3&(B
|
|
@ -336,17 +336,6 @@ function MigrateDefaultCharsets() {
|
|||
"@mozilla.org/charset-converter-manager;1"
|
||||
].getService(Ci.nsICharsetConverterManager);
|
||||
|
||||
let sendCharsetStr = Services.prefs.getComplexValue(
|
||||
"mailnews.send_default_charset",
|
||||
Ci.nsIPrefLocalizedString
|
||||
).data;
|
||||
|
||||
try {
|
||||
charsetConvertManager.getCharsetTitle(sendCharsetStr);
|
||||
} catch (e) {
|
||||
Services.prefs.clearUserPref("mailnews.send_default_charset");
|
||||
}
|
||||
|
||||
let viewCharsetStr = Services.prefs.getComplexValue(
|
||||
"mailnews.view_default_charset",
|
||||
Ci.nsIPrefLocalizedString
|
||||
|
|
|
@ -76,12 +76,6 @@ function run_test() {
|
|||
Ci.nsIPrefLocalizedString
|
||||
);
|
||||
charset.data = "VISCII";
|
||||
Services.prefs.setComplexValue(
|
||||
"mailnews.send_default_charset",
|
||||
Ci.nsIPrefLocalizedString,
|
||||
charset
|
||||
);
|
||||
Assert.ok(Services.prefs.prefHasUserValue("mailnews.send_default_charset"));
|
||||
Services.prefs.setComplexValue(
|
||||
"mailnews.view_default_charset",
|
||||
Ci.nsIPrefLocalizedString,
|
||||
|
@ -155,7 +149,6 @@ function run_test() {
|
|||
|
||||
// Migration should have cleared the charset user pref values.
|
||||
Assert.ok(Services.prefs.getIntPref("mail.default_charsets.migrated") > 0);
|
||||
Assert.ok(!Services.prefs.prefHasUserValue("mailnews.send_default_charset"));
|
||||
Assert.ok(!Services.prefs.prefHasUserValue("mailnews.view_default_charset"));
|
||||
|
||||
// Now migrate the prefs
|
||||
|
|
|
@ -35,8 +35,6 @@ interface nsIMsgCompFields : msgIWritableStructuredHeaders {
|
|||
attribute string references;
|
||||
attribute string priority;
|
||||
attribute string messageId;
|
||||
attribute string characterSet;
|
||||
readonly attribute string defaultCharacterSet;
|
||||
|
||||
attribute AString templateName;
|
||||
attribute string draftId;
|
||||
|
|
|
@ -107,9 +107,6 @@ interface nsIMsgCompose : nsIMsgSendListener {
|
|||
[optional] in mozIDOMWindowProxy aWindow,
|
||||
[optional] in nsIDocShell aDocShell);
|
||||
|
||||
/* ... */
|
||||
void SetDocumentCharset(in string charset);
|
||||
|
||||
/* ... */
|
||||
void RegisterStateListener(in nsIMsgComposeStateListener stateListener);
|
||||
|
||||
|
|
|
@ -115,6 +115,7 @@ nsMsgAttachmentHandler::nsMsgAttachmentHandler()
|
|||
mCompFields(nullptr), // Message composition fields for the sender
|
||||
m_bogus_attachment(false),
|
||||
m_done(false),
|
||||
m_charset("UTF-8"_ns),
|
||||
m_already_encoded_p(false),
|
||||
mDeleteFile(false),
|
||||
mMHTMLPart(false),
|
||||
|
@ -294,8 +295,7 @@ void nsMsgAttachmentHandler::AnalyzeSnarfedFile(void) {
|
|||
|
||||
// Given a content-type and some info about the contents of the document,
|
||||
// decide what encoding it should have.
|
||||
nsresult nsMsgAttachmentHandler::PickEncoding(const char* charset,
|
||||
nsIMsgSend* mime_delivery_state) {
|
||||
nsresult nsMsgAttachmentHandler::PickEncoding(nsIMsgSend* mime_delivery_state) {
|
||||
nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
|
||||
bool needsB64 = false;
|
||||
|
@ -361,22 +361,17 @@ nsresult nsMsgAttachmentHandler::PickEncoding(const char* charset,
|
|||
m_desiredType.Truncate();
|
||||
}
|
||||
|
||||
// If the Mail charset is multibyte, we force it to use Base64 for
|
||||
// attachments.
|
||||
if ((!mMainBody && charset && nsMsgI18Nmultibyte_charset(charset)) &&
|
||||
(m_type.LowerCaseEqualsLiteral(TEXT_HTML) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_MDL) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_PLAIN) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_RICHTEXT) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_ENRICHED) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_VCARD) ||
|
||||
m_type.LowerCaseEqualsLiteral(
|
||||
APPLICATION_DIRECTORY) || /* text/x-vcard synonym */
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_CSS) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_JSSS))) {
|
||||
if (!mMainBody && (m_type.LowerCaseEqualsLiteral(TEXT_HTML) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_MDL) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_PLAIN) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_RICHTEXT) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_ENRICHED) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_VCARD) ||
|
||||
m_type.LowerCaseEqualsLiteral(
|
||||
APPLICATION_DIRECTORY) || /* text/x-vcard synonym */
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_CSS) ||
|
||||
m_type.LowerCaseEqualsLiteral(TEXT_JSSS))) {
|
||||
needsB64 = true;
|
||||
} else if (charset && nsMsgI18Nstateful_charset(charset)) {
|
||||
m_encoding = ENCODING_7BIT;
|
||||
} else if (encode_p && m_unprintable_count > (m_size / 10)) {
|
||||
// If the document contains more than 10% unprintable characters,
|
||||
// then that seems like a good candidate for base64 instead of
|
||||
|
@ -452,7 +447,7 @@ DONE:
|
|||
}
|
||||
|
||||
nsresult nsMsgAttachmentHandler::PickCharset() {
|
||||
if (!m_charset.IsEmpty() ||
|
||||
if (mMainBody ||
|
||||
!StringBeginsWith(m_type, "text/"_ns, nsCaseInsensitiveCStringComparator))
|
||||
return NS_OK;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class nsMsgAttachmentHandler : public nsIMsgAttachmentHandler {
|
|||
|
||||
public:
|
||||
nsresult SnarfAttachment(nsMsgCompFields* compFields);
|
||||
nsresult PickEncoding(const char* charset, nsIMsgSend* mime_delivery_state);
|
||||
nsresult PickEncoding(nsIMsgSend* mime_delivery_state);
|
||||
nsresult PickCharset();
|
||||
void AnalyzeSnarfedFile(); // Analyze a previously-snarfed file.
|
||||
// (Currently only used for plaintext
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <iostream>
|
||||
#include "nsMsgCompose.h"
|
||||
#include "nsMsgCompFields.h"
|
||||
#include "nsMsgI18N.h"
|
||||
|
@ -77,15 +78,6 @@ nsMsgCompFields::nsMsgCompFields()
|
|||
m_needToCheckCharset = true;
|
||||
m_attachmentReminder = false;
|
||||
m_deliveryFormat = nsIMsgCompSendFormat::AskUser;
|
||||
|
||||
// Get the default charset from pref, use this as a mail charset.
|
||||
nsString charset;
|
||||
NS_GetLocalizedUnicharPreferenceWithDefault(
|
||||
nullptr, "mailnews.send_default_charset", u"UTF-8"_ns, charset);
|
||||
|
||||
LossyCopyUTF16toASCII(charset,
|
||||
m_DefaultCharacterSet); // Charsets better be ASCII
|
||||
SetCharacterSet(m_DefaultCharacterSet.get());
|
||||
}
|
||||
|
||||
nsMsgCompFields::~nsMsgCompFields() {}
|
||||
|
@ -277,15 +269,6 @@ NS_IMETHODIMP nsMsgCompFields::GetPriority(char** _retval) {
|
|||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgCompFields::SetCharacterSet(const char* value) {
|
||||
return SetAsciiHeader(MSG_CHARACTER_SET_HEADER_ID, value);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgCompFields::GetCharacterSet(char** _retval) {
|
||||
*_retval = strdup(GetAsciiHeader(MSG_CHARACTER_SET_HEADER_ID));
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgCompFields::SetMessageId(const char* value) {
|
||||
return SetAsciiHeader(MSG_MESSAGE_ID_HEADER_ID, value);
|
||||
}
|
||||
|
@ -555,8 +538,7 @@ NS_IMETHODIMP nsMsgCompFields::ConvertBodyToPlainText() {
|
|||
rv = GetBody(body);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
bool flowed, delsp, formatted, disallowBreaks;
|
||||
GetSerialiserFlags(GetCharacterSet(), &flowed, &delsp, &formatted,
|
||||
&disallowBreaks);
|
||||
GetSerialiserFlags("UTF-8", &flowed, &delsp, &formatted, &disallowBreaks);
|
||||
rv =
|
||||
ConvertBufToPlainText(body, flowed, delsp, formatted, disallowBreaks);
|
||||
if (NS_SUCCEEDED(rv)) rv = SetBody(body);
|
||||
|
@ -578,13 +560,6 @@ NS_IMETHODIMP nsMsgCompFields::SetComposeSecure(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgCompFields::GetDefaultCharacterSet(
|
||||
char** aDefaultCharacterSet) {
|
||||
NS_ENSURE_ARG_POINTER(aDefaultCharacterSet);
|
||||
*aDefaultCharacterSet = ToNewCString(m_DefaultCharacterSet);
|
||||
return *aDefaultCharacterSet ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgCompFields::GetNeedToCheckCharset(bool* _retval) {
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = m_needToCheckCharset;
|
||||
|
|
|
@ -490,8 +490,7 @@ char* mime_generate_attachment_headers(
|
|||
const char* description, const char* x_mac_type, const char* x_mac_creator,
|
||||
const char* real_name, const char* base_url, bool /*digest_p*/,
|
||||
nsMsgAttachmentHandler* /*ma*/, const char* attachmentCharset,
|
||||
const char* bodyCharset, bool bodyIsAsciiOnly, const char* content_id,
|
||||
bool aBodyDocument) {
|
||||
bool bodyIsAsciiOnly, const char* content_id, bool aBodyDocument) {
|
||||
NS_ASSERTION(encoding, "null encoding");
|
||||
|
||||
int32_t parmFolding = 2; // RFC 2231-compliant
|
||||
|
@ -573,8 +572,7 @@ char* mime_generate_attachment_headers(
|
|||
// Add format=flowed as in RFC 2646 if we are using that
|
||||
if (type && !PL_strcasecmp(type, "text/plain")) {
|
||||
bool flowed, delsp, formatted, disallowBreaks;
|
||||
GetSerialiserFlags(bodyCharset, &flowed, &delsp, &formatted,
|
||||
&disallowBreaks);
|
||||
GetSerialiserFlags("UTF-8", &flowed, &delsp, &formatted, &disallowBreaks);
|
||||
if (flowed) buf.AppendLiteral("; format=flowed");
|
||||
if (delsp) buf.AppendLiteral("; delsp=yes");
|
||||
// else
|
||||
|
@ -1162,7 +1160,7 @@ char* msg_make_filename_qtext(const char* srcText, bool stripCRLFs) {
|
|||
|
||||
// Rip apart the URL and extract a reasonable value for the `real_name' slot.
|
||||
void msg_pick_real_name(nsMsgAttachmentHandler* attachment,
|
||||
const char16_t* proposedName, const char* charset) {
|
||||
const char16_t* proposedName) {
|
||||
const char *s, *s2;
|
||||
|
||||
if (!attachment->m_realName.IsEmpty()) return;
|
||||
|
|
|
@ -76,7 +76,6 @@ char* mime_generate_attachment_headers(
|
|||
const char* real_name, const char* base_url, bool digest_p,
|
||||
nsMsgAttachmentHandler* ma,
|
||||
const char* attachmentCharset, // charset of the attachment (can be null)
|
||||
const char* bodyCharset, // charset of the main body
|
||||
bool bodyIsAsciiOnly, const char* content_id, bool aBodyDocument);
|
||||
|
||||
char* msg_generate_message_id(nsIMsgIdentity*);
|
||||
|
@ -95,7 +94,7 @@ char* msg_make_filename_qtext(const char* srcText, bool stripCRLFs);
|
|||
|
||||
// Rip apart the URL and extract a reasonable value for the `real_name' slot.
|
||||
void msg_pick_real_name(nsMsgAttachmentHandler* attachment,
|
||||
const char16_t* proposedName, const char* charset);
|
||||
const char16_t* proposedName);
|
||||
|
||||
//
|
||||
// Informational calls...
|
||||
|
|
|
@ -1057,24 +1057,6 @@ nsMsgCompose::Initialize(nsIMsgComposeParams* aParams,
|
|||
return CreateMessage(originalMsgURI.get(), type, composeFields);
|
||||
}
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
|
||||
nsMsgCompose::SetDocumentCharset(const char* aCharset) {
|
||||
NS_ENSURE_TRUE(m_compFields && m_editor, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// Set charset, this will be used for the MIME charset labeling.
|
||||
m_compFields->SetCharacterSet(aCharset);
|
||||
|
||||
// notify the change to editor
|
||||
nsCString charset;
|
||||
if (aCharset) charset = nsDependentCString(aCharset);
|
||||
if (m_editor) {
|
||||
nsCOMPtr<nsIEditor> editor(m_editor); // Strong reference.
|
||||
editor->SetDocumentCharacterSet(charset);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgCompose::RegisterStateListener(
|
||||
nsIMsgComposeStateListener* aStateListener) {
|
||||
|
@ -1236,7 +1218,6 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode,
|
|||
// Set content type based on which type of compose window we had.
|
||||
nsString contentType = (m_composeHTML) ? u"text/html"_ns : u"text/plain"_ns;
|
||||
nsString msgBody;
|
||||
const char* charset = m_compFields->GetCharacterSet();
|
||||
if (m_editor) {
|
||||
// Reset message body previously stored in the compose fields
|
||||
// There is 2 nsIMsgCompFields::SetBody() functions using a pointer as
|
||||
|
@ -1251,7 +1232,7 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode,
|
|||
nsIDocumentEncoder::OutputDisallowLineBreaking;
|
||||
} else {
|
||||
bool flowed, delsp, formatted, disallowBreaks;
|
||||
GetSerialiserFlags(charset, &flowed, &delsp, &formatted, &disallowBreaks);
|
||||
GetSerialiserFlags("UTF-8", &flowed, &delsp, &formatted, &disallowBreaks);
|
||||
if (flowed) flags |= nsIDocumentEncoder::OutputFormatFlowed;
|
||||
if (delsp) flags |= nsIDocumentEncoder::OutputFormatDelSp;
|
||||
if (formatted) flags |= nsIDocumentEncoder::OutputFormatted;
|
||||
|
@ -1270,41 +1251,15 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode,
|
|||
if (!StringEndsWith(msgBody, u"\r\n"_ns)) msgBody.AppendLiteral("\r\n");
|
||||
bool isAsciiOnly = mozilla::IsAsciiNullTerminated(
|
||||
static_cast<const char16_t*>(msgBody.get()));
|
||||
// Convert body to mail charset
|
||||
// Convert body to UTF-8
|
||||
nsCString outCString;
|
||||
rv = nsMsgI18NConvertFromUnicode(
|
||||
charset ? nsDependentCString(charset) : EmptyCString(), msgBody,
|
||||
outCString, true);
|
||||
outCString.Assign(NS_ConvertUTF16toUTF8(msgBody));
|
||||
if (m_compFields->GetForceMsgEncoding()) isAsciiOnly = false;
|
||||
if (NS_SUCCEEDED(rv) && !outCString.IsEmpty()) {
|
||||
// If the body contains characters outside the repertoire of the current
|
||||
// charset, just convert to UTF-8 and be done with it
|
||||
// unless disable_fallback_to_utf8 is set for this charset.
|
||||
if (NS_ERROR_UENC_NOMAPPING == rv) {
|
||||
bool needToCheckCharset;
|
||||
m_compFields->GetNeedToCheckCharset(&needToCheckCharset);
|
||||
if (needToCheckCharset) {
|
||||
bool disableFallback = false;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if (prefBranch && charset) {
|
||||
nsCString prefName("mailnews.disable_fallback_to_utf8.");
|
||||
prefName.Append(charset);
|
||||
prefBranch->GetBoolPref(prefName.get(), &disableFallback);
|
||||
}
|
||||
if (!disableFallback) {
|
||||
CopyUTF16toUTF8(msgBody, outCString);
|
||||
m_compFields->SetCharacterSet("UTF-8");
|
||||
SetDocumentCharset("UTF-8");
|
||||
}
|
||||
}
|
||||
}
|
||||
m_compFields->SetBodyIsAsciiOnly(isAsciiOnly);
|
||||
m_compFields->SetBody(outCString.get());
|
||||
} else {
|
||||
m_compFields->SetBody(NS_ConvertUTF16toUTF8(msgBody).get());
|
||||
m_compFields->SetCharacterSet("UTF-8");
|
||||
SetDocumentCharset("UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1509,37 +1464,6 @@ NS_IMETHODIMP nsMsgCompose::SetEditor(nsIEditor* aEditor) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult fixCharset(nsCString& aCharset) {
|
||||
// Convert to a canonical charset name.
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCString charset(aCharset);
|
||||
rv = ccm->GetCharsetAlias(charset.get(), aCharset);
|
||||
|
||||
// Replace an unrecognized charset with the default.
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCOMPtr<nsIPrefBranch> prefs(
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsString defaultCharset;
|
||||
NS_GetLocalizedUnicharPreferenceWithDefault(
|
||||
prefs, "mailnews.send_default_charset", u"UTF-8"_ns, defaultCharset);
|
||||
LossyCopyUTF16toASCII(defaultCharset, aCharset);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Don't accept UTF-16 ever. UTF-16 should never be selected as an
|
||||
// outgoing encoding for e-mail. MIME can't handle those messages
|
||||
// encoded in ASCII-incompatible encodings.
|
||||
if (StringBeginsWith(aCharset, "UTF-16"_ns)) {
|
||||
aCharset.AssignLiteral("UTF-8");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// This used to be called BEFORE editor was created
|
||||
// (it did the loadURI that triggered editor creation)
|
||||
// It is called from JS after editor creation
|
||||
|
@ -1552,11 +1476,7 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsMsgCompose::InitEditor(
|
|||
|
||||
m_editor = aEditor;
|
||||
|
||||
nsAutoCString msgCharSet(m_compFields->GetCharacterSet());
|
||||
rv = fixCharset(msgCharSet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
m_compFields->SetCharacterSet(msgCharSet.get());
|
||||
aEditor->SetDocumentCharacterSet(msgCharSet);
|
||||
aEditor->SetDocumentCharacterSet("UTF-8"_ns);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window =
|
||||
nsPIDOMWindowOuter::From(aContentWindow);
|
||||
|
@ -1564,10 +1484,8 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsMsgCompose::InitEditor(
|
|||
nsIDocShell* docShell = window->GetDocShell();
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// SetCharset will complain about "UTF-7" or "x-mac-croatian"
|
||||
// (see test-charset-edit.js), but we deal with this elsewhere.
|
||||
rv = docShell->SetCharset(msgCharSet);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetCharset() failed");
|
||||
rv = docShell->SetCharset("UTF-8"_ns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool quotingToFollow = false;
|
||||
GetQuotingToFollow("ingToFollow);
|
||||
|
@ -1779,23 +1697,6 @@ nsresult nsMsgCompose::CreateMessage(const char* originalMsgURI,
|
|||
// Note the early return at the end of the block.
|
||||
if (type == nsIMsgCompType::ForwardInline ||
|
||||
type == nsIMsgCompType::ReplyWithTemplate) {
|
||||
// Use charset set up in the compose fields by MIME unless we should
|
||||
// use the default charset.
|
||||
bool replyInDefault = false;
|
||||
prefs->GetBoolPref("mailnews.reply_in_default_charset", &replyInDefault);
|
||||
// Use send_default_charset if reply_in_default_charset is on.
|
||||
if (replyInDefault) {
|
||||
nsString str;
|
||||
nsCString charset;
|
||||
NS_GetLocalizedUnicharPreferenceWithDefault(
|
||||
prefs, "mailnews.send_default_charset", EmptyString(), str);
|
||||
if (!str.IsEmpty()) {
|
||||
LossyCopyUTF16toASCII(str, charset);
|
||||
m_compFields->SetCharacterSet(charset.get());
|
||||
mAnswerDefaultCharset = true;
|
||||
}
|
||||
}
|
||||
|
||||
// We want to treat this message as a reference too
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
rv = GetMsgDBHdrFromURI(originalMsgURI, getter_AddRefs(msgHdr));
|
||||
|
@ -1890,26 +1791,6 @@ nsresult nsMsgCompose::CreateMessage(const char* originalMsgURI,
|
|||
}
|
||||
if (msgHdr) {
|
||||
nsCString decodedCString;
|
||||
|
||||
bool replyInDefault = false;
|
||||
prefs->GetBoolPref("mailnews.reply_in_default_charset", &replyInDefault);
|
||||
// Use send_default_charset if reply_in_default_charset is on.
|
||||
if (replyInDefault) {
|
||||
nsString str;
|
||||
NS_GetLocalizedUnicharPreferenceWithDefault(
|
||||
prefs, "mailnews.send_default_charset", EmptyString(), str);
|
||||
if (!str.IsEmpty()) {
|
||||
LossyCopyUTF16toASCII(str, charset);
|
||||
mAnswerDefaultCharset = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the charset we determined, if any, in the comp fields.
|
||||
// For replies, the charset will be set after processing the message
|
||||
// through MIME in QuotingOutputStreamListener::OnStopRequest().
|
||||
if (isFirstPass && !charset.IsEmpty())
|
||||
m_compFields->SetCharacterSet(charset.get());
|
||||
|
||||
nsString subject;
|
||||
rv = msgHdr->GetMime2DecodedSubject(subject);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -2337,24 +2218,7 @@ QuotingOutputStreamListener::OnStopRequest(nsIRequest* request,
|
|||
mMimeConverter = do_GetService(NS_MIME_CONVERTER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
nsCString charset;
|
||||
compFields->GetCharacterSet(getter_Copies(charset));
|
||||
|
||||
if (!mCharsetFixed) {
|
||||
// Get the charset from the channel where MIME left it.
|
||||
if (mQuote) {
|
||||
nsCOMPtr<nsIChannel> quoteChannel;
|
||||
mQuote->GetQuoteChannel(getter_AddRefs(quoteChannel));
|
||||
if (quoteChannel) {
|
||||
quoteChannel->GetContentCharset(charset);
|
||||
if (!charset.IsEmpty()) {
|
||||
rv = fixCharset(charset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
compFields->SetCharacterSet(charset.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCString charset("UTF-8");
|
||||
|
||||
mHeaders->ExtractHeader(HEADER_FROM, true, outCString);
|
||||
nsMsgI18NConvertRawBytesToUTF16(outCString, charset, from);
|
||||
|
@ -2977,9 +2841,8 @@ nsMsgCompose::QuoteMessage(const char* msgURI) {
|
|||
|
||||
mQuoteStreamListener->SetComposeObj(this);
|
||||
|
||||
rv = mQuote->QuoteMessage(
|
||||
msgURI, false, mQuoteStreamListener,
|
||||
mCharsetOverride ? m_compFields->GetCharacterSet() : "", false, msgHdr);
|
||||
rv = mQuote->QuoteMessage(msgURI, false, mQuoteStreamListener,
|
||||
mCharsetOverride ? "UTF-8" : "", false, msgHdr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -716,7 +716,6 @@ NS_IMETHODIMP nsMsgTemplateReplyHelper::OnStopRunningUrl(nsIURI* aUrl,
|
|||
nsCString charset;
|
||||
rv = mTemplateHdr->GetCharset(getter_Copies(charset));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
compFields->SetCharacterSet(charset.get());
|
||||
rv = nsMsgI18NConvertToUnicode(charset, mTemplateBody, body);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"couldn't convert templ body to unicode");
|
||||
|
|
|
@ -503,7 +503,6 @@ nsMsgComposeAndSend::GatherMimeAttachments() {
|
|||
}
|
||||
|
||||
m_plaintext->m_type = TEXT_HTML;
|
||||
m_plaintext->m_charset = mCompFields->GetCharacterSet();
|
||||
m_plaintext->m_desiredType = TEXT_PLAIN;
|
||||
m_attachment_pending_count++;
|
||||
status = m_plaintext->SnarfAttachment(mCompFields);
|
||||
|
@ -542,7 +541,7 @@ nsMsgComposeAndSend::GatherMimeAttachments() {
|
|||
// generate a message id, if necessary
|
||||
GenerateMessageId();
|
||||
|
||||
mainbody = new nsMsgSendPart(this, mCompFields->GetCharacterSet());
|
||||
mainbody = new nsMsgSendPart(this);
|
||||
if (!mainbody) goto FAILMEM;
|
||||
|
||||
mainbody->SetMainPart(true);
|
||||
|
@ -556,9 +555,7 @@ nsMsgComposeAndSend::GatherMimeAttachments() {
|
|||
PR_FREEIF(m_attachment1_encoding);
|
||||
if (m_attachment1_body) mCompFields->GetBodyIsAsciiOnly(&body_is_us_ascii);
|
||||
|
||||
if (!mCompFields->GetForceMsgEncoding() &&
|
||||
(body_is_us_ascii ||
|
||||
nsMsgI18Nstateful_charset(mCompFields->GetCharacterSet()))) {
|
||||
if (!mCompFields->GetForceMsgEncoding() && body_is_us_ascii) {
|
||||
m_attachment1_encoding = PL_strdup(ENCODING_7BIT);
|
||||
} else if (mime_use_quoted_printable_p) {
|
||||
m_attachment1_encoding = PL_strdup(ENCODING_QUOTED_PRINTABLE);
|
||||
|
@ -612,7 +609,7 @@ nsMsgComposeAndSend::GatherMimeAttachments() {
|
|||
// OK. We have a plaintext version of the main body that we want to
|
||||
// send instead of or with the text/html. Shove it in.
|
||||
//
|
||||
plainpart = new nsMsgSendPart(this, mCompFields->GetCharacterSet());
|
||||
plainpart = new nsMsgSendPart(this);
|
||||
if (!plainpart) goto FAILMEM;
|
||||
status = plainpart->SetType(TEXT_PLAIN);
|
||||
if (NS_FAILED(status)) goto FAIL;
|
||||
|
@ -622,13 +619,12 @@ nsMsgComposeAndSend::GatherMimeAttachments() {
|
|||
m_plaintext->mMainBody = true;
|
||||
|
||||
// Determine Content-Transfer-Encoding for the attachments.
|
||||
m_plaintext->PickEncoding(mCompFields->GetCharacterSet(), this);
|
||||
const char* charset = mCompFields->GetCharacterSet();
|
||||
m_plaintext->PickEncoding(this);
|
||||
hdrs = mime_generate_attachment_headers(
|
||||
m_plaintext->m_type.get(), nullptr, m_plaintext->m_encoding.get(),
|
||||
m_plaintext->m_description.get(), m_plaintext->m_xMacType.get(),
|
||||
m_plaintext->m_xMacCreator.get(), nullptr, 0, m_digest_p, m_plaintext,
|
||||
charset, charset, body_is_us_ascii, nullptr, true);
|
||||
"UTF-8", body_is_us_ascii, nullptr, true);
|
||||
if (!hdrs) goto FAILMEM;
|
||||
status = plainpart->SetOtherHeaders(hdrs);
|
||||
PR_Free(hdrs);
|
||||
|
@ -763,11 +759,10 @@ nsMsgComposeAndSend::GatherMimeAttachments() {
|
|||
// so that we need not worry about duplicate header lines.
|
||||
//
|
||||
if ((!plainpart) || (plainpart != mainbody)) {
|
||||
const char* charset = mCompFields->GetCharacterSet();
|
||||
hdrs = mime_generate_attachment_headers(
|
||||
m_attachment1_type, nullptr, m_attachment1_encoding, 0, 0, 0, 0, 0,
|
||||
m_digest_p, nullptr, /* no "ma"! */
|
||||
charset, charset, mCompFields->GetBodyIsAsciiOnly(), nullptr, true);
|
||||
"UTF-8", mCompFields->GetBodyIsAsciiOnly(), nullptr, true);
|
||||
if (!hdrs) goto FAILMEM;
|
||||
status = mainbody->AppendOtherHeaders(hdrs);
|
||||
if (NS_FAILED(status)) goto FAIL;
|
||||
|
@ -928,7 +923,7 @@ int32_t nsMsgComposeAndSend::PreProcessPart(
|
|||
// we're never going to get one.
|
||||
if (ma->m_type.IsEmpty()) ma->m_type = UNKNOWN_CONTENT_TYPE;
|
||||
|
||||
ma->PickEncoding(mCompFields->GetCharacterSet(), this);
|
||||
ma->PickEncoding(this);
|
||||
ma->PickCharset();
|
||||
|
||||
part = new nsMsgSendPart(this);
|
||||
|
@ -969,9 +964,8 @@ int32_t nsMsgComposeAndSend::PreProcessPart(
|
|||
// we determine from
|
||||
// the file or none
|
||||
// at all!
|
||||
mCompFields->GetCharacterSet(),
|
||||
false, // bodyIsAsciiOnly to false
|
||||
// for attachments
|
||||
false, // bodyIsAsciiOnly to false
|
||||
// for attachments
|
||||
ma->m_contentId.get(), false);
|
||||
if (!hdrs) return 0;
|
||||
|
||||
|
@ -1356,59 +1350,21 @@ nsresult nsMsgComposeAndSend::GetBodyFromEditor() {
|
|||
}
|
||||
|
||||
nsCString attachment1_body;
|
||||
attachment1_body.Assign(NS_ConvertUTF16toUTF8(bodyText));
|
||||
|
||||
// Convert body to mail charset
|
||||
nsCString outCString;
|
||||
const char* aCharset = mCompFields->GetCharacterSet();
|
||||
bool isAsciiOnly = mozilla::IsAsciiNullTerminated(
|
||||
static_cast<const char16_t*>(bodyText.get()));
|
||||
if (mCompFields->GetForceMsgEncoding()) isAsciiOnly = false;
|
||||
mCompFields->SetBodyIsAsciiOnly(isAsciiOnly);
|
||||
|
||||
if (aCharset && *aCharset) {
|
||||
bool isAsciiOnly = mozilla::IsAsciiNullTerminated(
|
||||
static_cast<const char16_t*>(bodyText.get()));
|
||||
rv = nsMsgI18NConvertFromUnicode(nsDependentCString(aCharset), bodyText,
|
||||
outCString, true);
|
||||
if (mCompFields->GetForceMsgEncoding()) isAsciiOnly = false;
|
||||
mCompFields->SetBodyIsAsciiOnly(isAsciiOnly);
|
||||
|
||||
// If the body contains characters outside the current mail charset,
|
||||
// convert to UTF-8.
|
||||
if (NS_ERROR_UENC_NOMAPPING == rv) {
|
||||
bool needToCheckCharset;
|
||||
mCompFields->GetNeedToCheckCharset(&needToCheckCharset);
|
||||
if (needToCheckCharset) {
|
||||
// Just use UTF-8 and be done with it
|
||||
// unless disable_fallback_to_utf8 is set for this charset.
|
||||
bool disableFallback = false;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if (prefBranch) {
|
||||
nsCString prefName("mailnews.disable_fallback_to_utf8.");
|
||||
prefName.Append(aCharset);
|
||||
prefBranch->GetBoolPref(prefName.get(), &disableFallback);
|
||||
}
|
||||
if (!disableFallback) {
|
||||
CopyUTF16toUTF8(bodyText, outCString);
|
||||
mCompFields->SetCharacterSet("UTF-8");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) attachment1_body = outCString;
|
||||
|
||||
// If we have an origHTMLBody that is not null, this means that it is
|
||||
// different than the bodyText because of formatting conversions. Because of
|
||||
// this we need to do the charset conversion on this part separately
|
||||
if (!origHTMLBody.IsEmpty()) {
|
||||
nsCString newBody;
|
||||
rv = nsMsgI18NConvertFromUnicode(nsDependentCString(aCharset),
|
||||
origHTMLBody, newBody, true);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mOriginalHTMLBody = ToNewCString(newBody);
|
||||
}
|
||||
} else {
|
||||
mOriginalHTMLBody = ToNewCString(attachment1_body);
|
||||
}
|
||||
} else
|
||||
return NS_ERROR_FAILURE;
|
||||
// If we have an origHTMLBody that is not null, this means that it is
|
||||
// different than the bodyText because of formatting conversions. Because of
|
||||
// this we need to do the charset conversion on this part separately
|
||||
if (!origHTMLBody.IsEmpty()) {
|
||||
mOriginalHTMLBody = ToNewCString(NS_ConvertUTF16toUTF8(origHTMLBody));
|
||||
} else {
|
||||
mOriginalHTMLBody = ToNewCString(attachment1_body);
|
||||
}
|
||||
|
||||
rv = SnarfAndCopyBody(attachment1_body, TEXT_HTML);
|
||||
|
||||
|
@ -1512,12 +1468,9 @@ nsresult nsMsgComposeAndSend::ProcessMultipartRelated(int32_t* aMailboxCount,
|
|||
m_attachments[i]->m_xMacType = attachment->m_xMacType;
|
||||
m_attachments[i]->m_xMacCreator = attachment->m_xMacCreator;
|
||||
|
||||
m_attachments[i]->m_charset = mCompFields->GetCharacterSet();
|
||||
m_attachments[i]->m_encoding = ENCODING_7BIT;
|
||||
|
||||
if (m_attachments[i]->mURL)
|
||||
msg_pick_real_name(m_attachments[i], nullptr,
|
||||
mCompFields->GetCharacterSet());
|
||||
if (m_attachments[i]->mURL) msg_pick_real_name(m_attachments[i], nullptr);
|
||||
|
||||
if (m_attachments[i]->m_contentId.IsEmpty()) {
|
||||
//
|
||||
|
@ -1777,8 +1730,7 @@ nsresult nsMsgComposeAndSend::AddCompFieldLocalAttachments() {
|
|||
if (m_attachments[newLoc]->mURL) {
|
||||
nsAutoString proposedName;
|
||||
attachment->GetName(proposedName);
|
||||
msg_pick_real_name(m_attachments[newLoc], proposedName.get(),
|
||||
mCompFields->GetCharacterSet());
|
||||
msg_pick_real_name(m_attachments[newLoc], proposedName.get());
|
||||
}
|
||||
|
||||
// Now, most importantly, we need to figure out what the content type
|
||||
|
@ -1963,8 +1915,7 @@ nsresult nsMsgComposeAndSend::AddCompFieldRemoteAttachments(
|
|||
if (do_add_attachment) {
|
||||
nsAutoString proposedName;
|
||||
attachment->GetName(proposedName);
|
||||
msg_pick_real_name(m_attachments[newLoc], proposedName.get(),
|
||||
mCompFields->GetCharacterSet());
|
||||
msg_pick_real_name(m_attachments[newLoc], proposedName.get());
|
||||
++newLoc;
|
||||
}
|
||||
}
|
||||
|
@ -2039,13 +1990,10 @@ nsresult nsMsgComposeAndSend::HackAttachments(nsIArray* attachments,
|
|||
|
||||
attachedFile->GetType(m_attachments[i]->m_type);
|
||||
|
||||
// Set it to the compose fields for a default...
|
||||
m_attachments[i]->m_charset = mCompFields->GetCharacterSet();
|
||||
|
||||
// If we still don't have a content type, we should really try sniff one
|
||||
// out!
|
||||
if (m_attachments[i]->m_type.IsEmpty())
|
||||
m_attachments[i]->PickEncoding(mCompFields->GetCharacterSet(), this);
|
||||
m_attachments[i]->PickEncoding(this);
|
||||
|
||||
// For local files, if they are HTML docs and we don't have a charset, we
|
||||
// should sniff the file and see if we can figure it out.
|
||||
|
@ -2087,9 +2035,7 @@ nsresult nsMsgComposeAndSend::HackAttachments(nsIArray* attachments,
|
|||
!m_attachments[i]->m_encoding.LowerCaseEqualsLiteral(ENCODING_BINARY))
|
||||
m_attachments[i]->m_already_encoded_p = true;
|
||||
|
||||
if (m_attachments[i]->mURL)
|
||||
msg_pick_real_name(m_attachments[i], nullptr,
|
||||
mCompFields->GetCharacterSet());
|
||||
if (m_attachments[i]->mURL) msg_pick_real_name(m_attachments[i], nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2135,7 +2081,6 @@ nsresult nsMsgComposeAndSend::HackAttachments(nsIArray* attachments,
|
|||
attachment->GetUrl(getter_AddRefs(m_attachments[i]->mURL));
|
||||
|
||||
attachment->GetRealType(m_attachments[i]->m_overrideType);
|
||||
m_attachments[i]->m_charset = mCompFields->GetCharacterSet();
|
||||
attachment->GetRealEncoding(m_attachments[i]->m_overrideEncoding);
|
||||
attachment->GetDesiredType(m_attachments[i]->m_desiredType);
|
||||
attachment->GetDescription(m_attachments[i]->m_description);
|
||||
|
@ -2172,9 +2117,7 @@ nsresult nsMsgComposeAndSend::HackAttachments(nsIArray* attachments,
|
|||
do_CreateInstance(contractID.get());
|
||||
if (msgProtocolInfo) mailbox_count++;
|
||||
}
|
||||
if (uri)
|
||||
msg_pick_real_name(m_attachments[i], nullptr,
|
||||
mCompFields->GetCharacterSet());
|
||||
if (uri) msg_pick_real_name(m_attachments[i], nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2273,14 +2216,6 @@ nsresult nsMsgComposeAndSend::InitCompositionFields(
|
|||
mCompFields = new nsMsgCompFields();
|
||||
if (!mCompFields) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
const char* cset = fields->GetCharacterSet();
|
||||
// Make sure charset is sane...
|
||||
if (!cset || !*cset) {
|
||||
mCompFields->SetCharacterSet("UTF-8");
|
||||
} else {
|
||||
mCompFields->SetCharacterSet(fields->GetCharacterSet());
|
||||
}
|
||||
|
||||
// Now, we will look for a URI defined as the default FCC pref. If this is
|
||||
// set, then SetFcc will use this value. The FCC field is a URI for the server
|
||||
// that will hold the "Sent" folder...the
|
||||
|
@ -2555,7 +2490,7 @@ nsresult nsMsgComposeAndSend::AddMailFollowupToHeader() {
|
|||
|
||||
// Set Mail-Followup-To
|
||||
return mCompFields->SetRawHeader(HEADER_MAIL_FOLLOWUP_TO, recipients,
|
||||
mCompFields->GetCharacterSet());
|
||||
"UTF-8");
|
||||
}
|
||||
|
||||
// Add Mail-Reply-To header
|
||||
|
@ -2623,8 +2558,7 @@ nsresult nsMsgComposeAndSend::AddMailReplyToHeader() {
|
|||
else
|
||||
mailReplyTo = replyTo;
|
||||
|
||||
mCompFields->SetRawHeader(HEADER_MAIL_REPLY_TO, mailReplyTo,
|
||||
mCompFields->GetCharacterSet());
|
||||
mCompFields->SetRawHeader(HEADER_MAIL_REPLY_TO, mailReplyTo, "UTF-8");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2990,9 +2924,8 @@ nsresult nsMsgComposeAndSend::DeliverFileAsMail() {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Ok, now MIME II encode this to prevent 8bit problems...
|
||||
char* convbuf =
|
||||
nsMsgI18NEncodeMimePartIIStr(buf, true, mCompFields->GetCharacterSet(), 0,
|
||||
nsMsgMIMEGetConformToStandard());
|
||||
char* convbuf = nsMsgI18NEncodeMimePartIIStr(buf, true, "UTF-8", 0,
|
||||
nsMsgMIMEGetConformToStandard());
|
||||
if (convbuf) {
|
||||
// MIME-PartII conversion
|
||||
PR_FREEIF(buf);
|
||||
|
@ -4163,9 +4096,9 @@ nsresult nsMsgComposeAndSend::MimeDoFCC(nsIFile* input_file,
|
|||
#endif
|
||||
) {
|
||||
char* convBcc;
|
||||
convBcc = nsMsgI18NEncodeMimePartIIStr(
|
||||
bcc_header, true, mCompFields->GetCharacterSet(), sizeof("BCC: "),
|
||||
nsMsgMIMEGetConformToStandard());
|
||||
convBcc =
|
||||
nsMsgI18NEncodeMimePartIIStr(bcc_header, true, "UTF-8", sizeof("BCC: "),
|
||||
nsMsgMIMEGetConformToStandard());
|
||||
|
||||
int32_t L = strlen(convBcc ? convBcc : bcc_header) + 20;
|
||||
char* buf = (char*)PR_Malloc(L);
|
||||
|
@ -4471,14 +4404,12 @@ nsMsgComposeAndSend::GetSendCompFields(nsIMsgCompFields** aCompFields) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsMsgComposeAndSend::GetSendBody(nsAString& aBody) {
|
||||
nsCString charSet;
|
||||
if (mCompFields) mCompFields->GetCharacterSet(getter_Copies(charSet));
|
||||
if (!m_attachment1_body) {
|
||||
aBody.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
return nsMsgI18NConvertToUnicode(
|
||||
charSet, nsDependentCString(m_attachment1_body), aBody);
|
||||
"UTF-8"_ns, nsDependentCString(m_attachment1_body), aBody);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -26,10 +26,7 @@ static char* mime_mailto_stream_read_buffer = 0;
|
|||
|
||||
int32_t nsMsgSendPart::M_counter = 0;
|
||||
|
||||
nsMsgSendPart::nsMsgSendPart(nsIMsgSend* state, const char* part_charset) {
|
||||
PL_strncpy(m_charset_name, (part_charset ? part_charset : "UTF-8"),
|
||||
sizeof(m_charset_name) - 1);
|
||||
m_charset_name[sizeof(m_charset_name) - 1] = '\0';
|
||||
nsMsgSendPart::nsMsgSendPart(nsIMsgSend* state) {
|
||||
m_children = nullptr;
|
||||
m_numchildren = 0;
|
||||
// if we're not added as a child, the default part number will be "1".
|
||||
|
@ -456,8 +453,8 @@ nsresult nsMsgSendPart::Write() {
|
|||
bool needsCharset = mime_type_needs_charset(m_type ? m_type : TEXT_PLAIN);
|
||||
if (needsCharset) {
|
||||
content_type_header =
|
||||
PR_smprintf("Content-Type: %s; charset=%s" CRLF,
|
||||
(m_type ? m_type : TEXT_PLAIN), m_charset_name);
|
||||
PR_smprintf("Content-Type: %s; charset=UTF-8" CRLF,
|
||||
(m_type ? m_type : TEXT_PLAIN));
|
||||
} else
|
||||
content_type_header = PR_smprintf("Content-Type: %s" CRLF,
|
||||
(m_type ? m_type : TEXT_PLAIN));
|
||||
|
|
|
@ -24,7 +24,7 @@ class nsMsgSendPart {
|
|||
typedef mozilla::mailnews::MimeEncoder MimeEncoder;
|
||||
|
||||
public:
|
||||
explicit nsMsgSendPart(nsIMsgSend* state, const char* part_charset = NULL);
|
||||
explicit nsMsgSendPart(nsIMsgSend* state);
|
||||
virtual ~nsMsgSendPart(); // Note that the destructor also destroys
|
||||
// any children that were added.
|
||||
|
||||
|
@ -39,8 +39,6 @@ class nsMsgSendPart {
|
|||
virtual nsresult SetType(const char* type);
|
||||
const char* GetType() { return m_type; }
|
||||
|
||||
const char* GetCharsetName() { return m_charset_name; }
|
||||
|
||||
virtual nsresult SetOtherHeaders(const char* other);
|
||||
const char* SetOtherHeaders() { return m_other; }
|
||||
virtual nsresult AppendOtherHeaders(const char* moreother);
|
||||
|
@ -78,7 +76,6 @@ class nsMsgSendPart {
|
|||
char* m_buffer;
|
||||
char* m_type;
|
||||
char* m_other;
|
||||
char m_charset_name[64 + 1]; // charset name associated with this part
|
||||
bool m_strip_sensitive_headers;
|
||||
mozilla::UniquePtr<MimeEncoder> m_encoder;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ var ParamFoldingPref = {
|
|||
|
||||
var expectedCTList0 = {
|
||||
RFC2047:
|
||||
"Content-Type: text/plain; charset=US-ASCII;\r\n" +
|
||||
"Content-Type: text/plain; charset=UTF-8;\r\n" +
|
||||
' name="=?UTF-8?B?ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJ?=' +
|
||||
"=?UTF-8?Q?JKLMNOPQRSTUVWXYZ=5b=5c=5d=5e=5f=60abcdefghijklmnopqrstuvwx?=" +
|
||||
"=?UTF-8?B?eXp7fH1+wqDCocKiwqPCpMKlwqbCp8KowqnCqsKrwqzCrcKuwq/CsMKx?=" +
|
||||
|
@ -62,7 +62,7 @@ var expectedCTList0 = {
|
|||
'=?UTF-8?B?w7HDssOzw7TDtcO2w7fDuMO5w7rDu8O8w73DvsO/LnR4dA==?="\r\n',
|
||||
|
||||
RFC2047WithCRLF:
|
||||
"Content-Type: text/plain; charset=US-ASCII;\r\n" +
|
||||
"Content-Type: text/plain; charset=UTF-8;\r\n" +
|
||||
' name="=?UTF-8?B?ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJ?=\r\n' +
|
||||
" =?UTF-8?Q?JKLMNOPQRSTUVWXYZ=5b=5c=5d=5e=5f=60abcdefghijklmnopqrstuvwx?=\r\n" +
|
||||
" =?UTF-8?B?eXp7fH1+wqDCocKiwqPCpMKlwqbCp8KowqnCqsKrwqzCrcKuwq/CsMKx?=\r\n" +
|
||||
|
@ -71,19 +71,19 @@ var expectedCTList0 = {
|
|||
" =?UTF-8?B?w5zDncOew5/DoMOhw6LDo8Okw6XDpsOnw6jDqcOqw6vDrMOtw67Dr8Ow?=\r\n" +
|
||||
' =?UTF-8?B?w7HDssOzw7TDtcO2w7fDuMO5w7rDu8O8w73DvsO/LnR4dA==?="\r\n',
|
||||
|
||||
RFC2231: "Content-Type: text/plain; charset=US-ASCII\r\n",
|
||||
RFC2231: "Content-Type: text/plain; charset=UTF-8\r\n",
|
||||
};
|
||||
|
||||
var expectedCTList1 = {
|
||||
RFC2047:
|
||||
"Content-Type: text/plain; charset=US-ASCII;\r\n" +
|
||||
"Content-Type: text/plain; charset=UTF-8;\r\n" +
|
||||
' name="!\\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~.txt"\r\n',
|
||||
|
||||
RFC2047WithCRLF:
|
||||
"Content-Type: text/plain; charset=US-ASCII;\r\n" +
|
||||
"Content-Type: text/plain; charset=UTF-8;\r\n" +
|
||||
' name="!\\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~.txt"\r\n',
|
||||
|
||||
RFC2231: "Content-Type: text/plain; charset=US-ASCII\r\n",
|
||||
RFC2231: "Content-Type: text/plain; charset=UTF-8\r\n",
|
||||
};
|
||||
|
||||
function checkAttachment(expectedCD, expectedCT) {
|
||||
|
|
|
@ -215,8 +215,8 @@ function testReply(aHrdIdx, aTemplateHdrIdx = 0) {
|
|||
// The text gets converted to UTF-8 (regardless of what it is) at some point.
|
||||
// Suspect a bug with how BinaryInputStream handles the strings.
|
||||
if (templateHdr.Charset == "windows-1252") {
|
||||
// XXX: should really check for "<EFBFBD><EFBFBD><EFBFBD> åäö"
|
||||
if (!body.includes("åäö xlatin1")) {
|
||||
// XXX: should really check for "åäö xlatin1"
|
||||
if (!body.includes("åäö xlatin1")) {
|
||||
// template-latin1 contains this
|
||||
do_throw(
|
||||
"latin1 body didn't go through! hdr msgid=" +
|
||||
|
|
|
@ -121,7 +121,6 @@ async function testBodyWithLongLine() {
|
|||
fields.from = "Nobody <nobody@tinderbox.invalid>";
|
||||
fields.to = "Nobody <nobody@tinderbox.invalid>";
|
||||
fields.subject = "Message with 1200 byte line in body";
|
||||
fields.characterSet = "UTF-8";
|
||||
let htmlMessage =
|
||||
"<html><head>" +
|
||||
'<meta http-equiv="content-type" content="text/html; charset=utf-8">' +
|
||||
|
@ -182,9 +181,7 @@ async function testBodyWithLongLine() {
|
|||
longMultibyteLineCJK + " " + newline + newline // Expected body: The message without the tags.
|
||||
);
|
||||
|
||||
// Now a special test for ISO-2022-JP.
|
||||
fields.characterSet = "ISO-2022-JP";
|
||||
|
||||
// Now a test for ISO-2022-JP.
|
||||
fields.forcePlainText = false;
|
||||
htmlMessage =
|
||||
"<html><head>" +
|
||||
|
@ -196,11 +193,10 @@ async function testBodyWithLongLine() {
|
|||
await richCreateMessage(fields, [], identity);
|
||||
checkDraftHeadersAndBody(
|
||||
{
|
||||
"Content-Type": "text/html; charset=ISO-2022-JP",
|
||||
"Content-Type": "text/html; charset=UTF-8",
|
||||
"Content-Transfer-Encoding": "base64",
|
||||
},
|
||||
htmlMessage,
|
||||
"ISO-2022-JP"
|
||||
htmlMessage
|
||||
);
|
||||
|
||||
// Again, but this time as plain text.
|
||||
|
@ -209,25 +205,14 @@ async function testBodyWithLongLine() {
|
|||
fields.useMultipartAlternative = false;
|
||||
await richCreateMessage(fields, [], identity);
|
||||
|
||||
// Expected body: The message without the tags and chopped up in
|
||||
// chunks of 36 characters with a space appended to each line.
|
||||
let expectedBody = "";
|
||||
let lastIndex = 0;
|
||||
for (let i = 0; i + 36 < longMultibyteLineJapanese.length; i = i + 36) {
|
||||
expectedBody =
|
||||
expectedBody + longMultibyteLineJapanese.substr(i, 36) + " \r\n";
|
||||
lastIndex = i + 36;
|
||||
}
|
||||
expectedBody += longMultibyteLineJapanese.substr(lastIndex) + "\r\n";
|
||||
let expectedBody = longMultibyteLineJapanese + " \n\n";
|
||||
|
||||
checkDraftHeadersAndBody(
|
||||
{
|
||||
"Content-Type":
|
||||
"text/plain; charset=ISO-2022-JP; format=flowed; delsp=yes",
|
||||
"Content-Transfer-Encoding": "7bit",
|
||||
"Content-Type": "text/plain; charset=UTF-8; format=flowed",
|
||||
"Content-Transfer-Encoding": "base64",
|
||||
},
|
||||
expectedBody,
|
||||
"ISO-2022-JP"
|
||||
expectedBody
|
||||
);
|
||||
|
||||
// Again, but this time not flowed.
|
||||
|
@ -237,11 +222,10 @@ async function testBodyWithLongLine() {
|
|||
await richCreateMessage(fields, [], identity);
|
||||
checkDraftHeadersAndBody(
|
||||
{
|
||||
"Content-Type": "text/plain; charset=ISO-2022-JP",
|
||||
"Content-Transfer-Encoding": "7bit",
|
||||
"Content-Type": "text/plain; charset=UTF-8",
|
||||
"Content-Transfer-Encoding": "base64",
|
||||
},
|
||||
expectedBody.replace(/ /g, ""), // No spaces expected this time.
|
||||
"ISO-2022-JP"
|
||||
expectedBody.replace(/ /g, "") // No spaces expected this time.
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -391,15 +391,6 @@ async function testContentHeaders() {
|
|||
"Content-Transfer-Encoding": "8bit",
|
||||
});
|
||||
|
||||
// What if we change the message charset?
|
||||
fields.characterSet = "ISO-8859-1";
|
||||
fields.body = "Archæologist";
|
||||
await richCreateMessage(fields, [], identity);
|
||||
checkDraftHeaders({
|
||||
"Content-Type": "text/html; charset=ISO-8859-1",
|
||||
"Content-Transfer-Encoding": "8bit",
|
||||
});
|
||||
|
||||
// Attachments
|
||||
fields.body = "";
|
||||
let plainAttachment = makeAttachment({
|
||||
|
@ -414,7 +405,7 @@ async function testContentHeaders() {
|
|||
await richCreateMessage(fields, [plainAttachment], identity);
|
||||
checkDraftHeaders(
|
||||
{
|
||||
"Content-Type": "text/html; charset=ISO-8859-1",
|
||||
"Content-Type": "text/html; charset=UTF-8",
|
||||
"Content-Transfer-Encoding": "7bit",
|
||||
},
|
||||
"1"
|
||||
|
@ -453,7 +444,6 @@ async function testContentHeaders() {
|
|||
);
|
||||
checkDraftHeaders(httpAttachmentHeaders, "2");
|
||||
|
||||
fields.characterSet = "UTF-8";
|
||||
let cloudAttachment = makeAttachment({
|
||||
url: Services.io.newFileURI(do_get_file("data/test-UTF-8.txt")).spec,
|
||||
sendViaCloud: true,
|
||||
|
|
|
@ -381,7 +381,6 @@ function openComposeWindowForRSSArticle(
|
|||
|
||||
params.composeFields = composeFields;
|
||||
params.composeFields.subject = subject;
|
||||
params.composeFields.characterSet = msgHdr.Charset;
|
||||
params.composeFields.body = "";
|
||||
params.bodyIsLink = false;
|
||||
params.identity = aIdentity;
|
||||
|
|
|
@ -252,7 +252,6 @@ nsresult nsOutlookCompose::ComposeTheMessage(nsMsgDeliverMode mode,
|
|||
headers->UnfoldValue(CMapiMessageHeaders::hdrSubject, unival,
|
||||
msg.GetBodyCharset());
|
||||
m_pMsgFields->SetSubject(unival);
|
||||
m_pMsgFields->SetCharacterSet(msg.GetBodyCharset());
|
||||
headers->UnfoldValue(CMapiMessageHeaders::hdrCc, unival,
|
||||
msg.GetBodyCharset());
|
||||
m_pMsgFields->SetCc(unival);
|
||||
|
|
|
@ -294,14 +294,8 @@ pref("mailnews.offline_sync_send_unsent", true);
|
|||
pref("mailnews.offline_sync_work_offline", false);
|
||||
pref("mailnews.force_ascii_search", false);
|
||||
|
||||
pref("mailnews.send_default_charset", "chrome://messenger/locale/messenger.properties");
|
||||
pref("mailnews.view_default_charset", "chrome://messenger/locale/messenger.properties");
|
||||
pref("mailnews.force_charset_override", false); // ignore specified MIME encoding and use the default encoding for display
|
||||
pref("mailnews.reply_in_default_charset", false);
|
||||
// mailnews.disable_fallback_to_utf8.<charset>
|
||||
// don't fallback from <charset> to UTF-8 even if some characters are not found in <charset>.
|
||||
// those characters will be crippled.
|
||||
pref("mailnews.disable_fallback_to_utf8.ISO-2022-JP", false);
|
||||
|
||||
// AppleDouble is causing problems with some webmail clients and Microsoft mail servers
|
||||
// rejecting a MIME part of multipart/appledouble. Mac uses resource forks less and less
|
||||
|
|
|
@ -314,10 +314,6 @@ nsresult CreateCompositionFields(
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(cFields, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Now set all of the passed in stuff...
|
||||
cFields->SetCharacterSet(!PL_strcasecmp("us-ascii", charset) ? "ISO-8859-1"
|
||||
: charset);
|
||||
|
||||
nsAutoCString val;
|
||||
nsAutoString outString;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче