Bug 1701450 - Prevent error when attachment name is empty in MessageSend.jsm. r=mkmelin
Also fix error msg of NS_MSG_ERROR_ATTACHING_FILE. Differential Revision: https://phabricator.services.mozilla.com/D110054 --HG-- extra : amend_source : 0b3a54db2a7b7a9fce30c3bf927c4ff3098c484b
This commit is contained in:
Родитель
9742ff046f
Коммит
c96bef7839
|
@ -120,7 +120,14 @@ MessageSend.prototype = {
|
||||||
messageFile = await this._message.createMessageFile();
|
messageFile = await this._message.createMessageFile();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
MsgUtils.sendLogger.error(e);
|
MsgUtils.sendLogger.error(e);
|
||||||
this.fail(e.result || Cr.NS_ERROR_FAILURE);
|
let errorMsg = "";
|
||||||
|
if (e.result == MsgUtils.NS_MSG_ERROR_ATTACHING_FILE) {
|
||||||
|
errorMsg = this._composeBundle.formatStringFromName(
|
||||||
|
"errorAttachingFile",
|
||||||
|
[e.data.name || e.data.url]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.fail(e.result || Cr.NS_ERROR_FAILURE, errorMsg);
|
||||||
this.notifyListenerOnStopSending(null, e.result, null, null);
|
this.notifyListenerOnStopSending(null, e.result, null, null);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +294,9 @@ MessageSend.prototype = {
|
||||||
let prompter = Cc["@mozilla.org/prompter;1"].getService(
|
let prompter = Cc["@mozilla.org/prompter;1"].getService(
|
||||||
Ci.nsIPromptFactory
|
Ci.nsIPromptFactory
|
||||||
);
|
);
|
||||||
return prompter.getPrompt(this._parentWindow, Ci.nsIPrompt);
|
try {
|
||||||
|
return prompter.getPrompt(this._parentWindow, Ci.nsIPrompt);
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
// If we cannot find a prompter, try the mail3Pane window.
|
// If we cannot find a prompter, try the mail3Pane window.
|
||||||
let prompt;
|
let prompt;
|
||||||
|
@ -378,7 +387,7 @@ MessageSend.prototype = {
|
||||||
let folder = MailUtils.getOrCreateFolder(this._folderUri);
|
let folder = MailUtils.getOrCreateFolder(this._folderUri);
|
||||||
let accountName = folder?.server.prettyName;
|
let accountName = folder?.server.prettyName;
|
||||||
if (!this._fcc || !localFoldersAccountName || !accountName) {
|
if (!this._fcc || !localFoldersAccountName || !accountName) {
|
||||||
this.fail(Cr.NS_OK, null, status);
|
this.fail(Cr.NS_OK, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,10 @@ const NS_ERROR_MODULE_MAILNEWS = 16;
|
||||||
*/
|
*/
|
||||||
function generateNSError(code) {
|
function generateNSError(code) {
|
||||||
return (
|
return (
|
||||||
(1 << 31) |
|
((1 << 31) |
|
||||||
((NS_ERROR_MODULE_MAILNEWS + NS_ERROR_MODULE_BASE_OFFSET) << 16) |
|
((NS_ERROR_MODULE_MAILNEWS + NS_ERROR_MODULE_BASE_OFFSET) << 16) |
|
||||||
code
|
code) >>>
|
||||||
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,11 +242,14 @@ class MimePart {
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
// File name can contain non-ASCII chars, encode according to RFC 2231.
|
// File name can contain non-ASCII chars, encode according to RFC 2231.
|
||||||
let encodedName = MsgUtils.rfc2047EncodeParam(this._bodyAttachment.name);
|
let encodedName, encodedFileName;
|
||||||
let encodedFileName = MsgUtils.rfc2231ParamFolding(
|
if (this._bodyAttachment.name) {
|
||||||
"filename",
|
encodedName = MsgUtils.rfc2047EncodeParam(this._bodyAttachment.name);
|
||||||
this._bodyAttachment.name
|
encodedFileName = MsgUtils.rfc2231ParamFolding(
|
||||||
);
|
"filename",
|
||||||
|
this._bodyAttachment.name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let buf = await res.arrayBuffer();
|
let buf = await res.arrayBuffer();
|
||||||
let content = jsmime.mimeutils.typedArrayToString(new Uint8Array(buf));
|
let content = jsmime.mimeutils.typedArrayToString(new Uint8Array(buf));
|
||||||
|
@ -256,14 +259,16 @@ class MimePart {
|
||||||
if (this._charset) {
|
if (this._charset) {
|
||||||
contentTypeParams += `; charset=${this._charset}`;
|
contentTypeParams += `; charset=${this._charset}`;
|
||||||
}
|
}
|
||||||
if (parmFolding != 2) {
|
if (encodedName && parmFolding != 2) {
|
||||||
contentTypeParams += `; name="${encodedName}"`;
|
contentTypeParams += `; name="${encodedName}"`;
|
||||||
}
|
}
|
||||||
this.setHeader("content-type", `${this._contentType}${contentTypeParams}`);
|
this.setHeader("content-type", `${this._contentType}${contentTypeParams}`);
|
||||||
this.setHeader(
|
if (encodedFileName) {
|
||||||
"content-disposition",
|
this.setHeader(
|
||||||
`${this._contentDisposition}; ${encodedFileName}`
|
"content-disposition",
|
||||||
);
|
`${this._contentDisposition}; ${encodedFileName}`
|
||||||
|
);
|
||||||
|
}
|
||||||
if (this._contentId) {
|
if (this._contentId) {
|
||||||
this.setHeader("content-id", `<${this._contentId}>`);
|
this.setHeader("content-id", `<${this._contentId}>`);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче