aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Brunschwig <[email protected]>2019-03-13 18:30:52 +0100
committerPatrick Brunschwig <[email protected]>2019-03-13 18:30:52 +0100
commit2c37decaa07c98cd24007326fb10a201e9a2efdf (patch)
treee5e5da7f81714e30c7e2c8f14f126981e181851d
parent662d7026b22ecf94830dd9bddd270075855c4998 (diff)
downloadenigmail-tb-67-preparation.tar.gz
enigmail-tb-67-preparation.tar.bz2
enigmail-tb-67-preparation.zip
made code compatible with TB 60 and 67tb-67-preparation
-rw-r--r--ipc/modules/enigmailprocess_common.jsm34
-rw-r--r--ipc/modules/enigmailprocess_unix.jsm2
-rw-r--r--package/autoSetup.jsm36
-rw-r--r--package/install.rdf2
-rw-r--r--package/mimeDecrypt.jsm140
-rw-r--r--package/mimeEncrypt.jsm22
-rw-r--r--package/mimeVerify.jsm83
-rw-r--r--package/pEpDecrypt.jsm31
-rw-r--r--package/pgpmimeHandler.jsm23
-rw-r--r--package/socks5Proxy.jsm25
-rw-r--r--package/streams.jsm23
-rw-r--r--package/tb60compat.jsm10
-rw-r--r--package/tests/mimeDecrypt-test.js10
-rw-r--r--package/wksMimeHandler.jsm17
-rw-r--r--stdlib/msgHdrUtils.jsm17
-rw-r--r--ui/content/enigmailMessengerOverlay.js18
16 files changed, 320 insertions, 173 deletions
diff --git a/ipc/modules/enigmailprocess_common.jsm b/ipc/modules/enigmailprocess_common.jsm
index d803e6a9..8168f6f6 100644
--- a/ipc/modules/enigmailprocess_common.jsm
+++ b/ipc/modules/enigmailprocess_common.jsm
@@ -20,10 +20,7 @@ var {
const XPCOMUtils = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm").XPCOMUtils;
Components.utils.importGlobalProperties(["TextDecoder", "TextEncoder"]);
-XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown",
- "resource://gre/modules/AsyncShutdown.jsm"); /* global AsyncShutdown: false */
-XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
- "resource://gre/modules/Timer.jsm"); /* global Timer: false */
+var _AsyncShutdown, _setTimeout;
var SubScriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
SubScriptLoader.loadSubScript("chrome://enigmail/content/modules/enigmailprocess_shared.js", this);
@@ -34,6 +31,21 @@ const BUFFER_SIZE = 32768;
let nextResponseId = 0;
+
+function getAsyncShutdown() {
+ if (!_AsyncShutdown) {
+ _AsyncShutdown = ChromeUtils.import("resource://gre/modules/AsyncShutdown.jsm").AsyncShutdown;
+ }
+ return _AsyncShutdown;
+}
+
+function getSetTimeout() {
+ if (!_setTimeout) {
+ _setTimeout = ChromeUtils.import("resource://gre/modules/Timer.jsm").setTimeout;
+ }
+ return _setTimeout;
+}
+
/* global SubprocessConstants: true */
/**
@@ -41,7 +53,7 @@ let nextResponseId = 0;
* resolves when the message has been received and the operation it triggers is
* complete.
*/
-class PromiseWorker extends ChromeWorker {
+class _PromiseWorker extends ChromeWorker {
constructor(url) {
super(url);
@@ -56,13 +68,13 @@ class PromiseWorker extends ChromeWorker {
this.addEventListener("message", this.onmessage);
this.shutdown = this.shutdown.bind(this);
- AsyncShutdown.webWorkersShutdown.addBlocker(
+ getAsyncShutdown().webWorkersShutdown.addBlocker(
"Subprocess.jsm: Shut down IO worker",
this.shutdown);
}
onClose() {
- AsyncShutdown.webWorkersShutdown.removeBlocker(this.shutdown);
+ getAsyncShutdown().webWorkersShutdown.removeBlocker(this.shutdown);
}
shutdown() {
@@ -184,6 +196,8 @@ class PromiseWorker extends ChromeWorker {
}
}
+var PromiseWorker = _PromiseWorker;
+
/**
* Represents an input or output pipe connected to a subprocess.
*
@@ -581,7 +595,7 @@ class InputPipe extends Pipe {
/**
* Represents a currently-running process, and allows interaction with it.
*/
-class BaseProcess {
+class _BaseProcess {
/**
* @param {PromiseWorker} worker
* The worker instance which owns the process.
@@ -711,7 +725,7 @@ class BaseProcess {
this.worker.call("kill", [this.id, force]);
if (!force) {
- setTimeout(() => {
+ getSetTimeout()(() => {
if (this.exitCode === null) {
this.worker.call("kill", [this.id, true]);
}
@@ -739,3 +753,5 @@ class BaseProcess {
return this.exitPromise;
}
}
+
+var BaseProcess = _BaseProcess;
diff --git a/ipc/modules/enigmailprocess_unix.jsm b/ipc/modules/enigmailprocess_unix.jsm
index bb411b53..4a28e101 100644
--- a/ipc/modules/enigmailprocess_unix.jsm
+++ b/ipc/modules/enigmailprocess_unix.jsm
@@ -30,7 +30,7 @@ var {
SubprocessConstants,
BaseProcess,
PromiseWorker
-} = ChromeUtils.import("chrome://enigmail/content/modules/enigmailprocess_common.jsm");
+} = ChromeUtils.import("chrome://enigmail/content/modules/enigmailprocess_common.jsm", this);
Services.scriptloader.loadSubScript("chrome://enigmail/content/modules/enigmailprocess_shared.js", this);
Services.scriptloader.loadSubScript("chrome://enigmail/content/modules/enigmailprocess_shared_unix.js", this);
diff --git a/package/autoSetup.jsm b/package/autoSetup.jsm
index 3913c0ca..c39633cb 100644
--- a/package/autoSetup.jsm
+++ b/package/autoSetup.jsm
@@ -26,6 +26,7 @@ const EnigmailTb60Compat = ChromeUtils.import("chrome://enigmail/content/modules
const jsmime = ChromeUtils.import("resource:///modules/jsmime.jsm").jsmime;
const EnigmailWks = ChromeUtils.import("chrome://enigmail/content/modules/webKey.jsm").EnigmailWks;
const EnigmailTimer = ChromeUtils.import("chrome://enigmail/content/modules/timer.jsm").EnigmailTimer;
+const EnigmailStreams = ChromeUtils.import("chrome://enigmail/content/modules/streams.jsm").EnigmailStreams;
// Interfaces
const nsIFolderLookupService = Ci.nsIFolderLookupService;
@@ -421,35 +422,6 @@ var EnigmailAutoSetup = {
};
-function createStreamListener(k) {
- return {
- _data: "",
- _stream: null,
-
- QueryInterface: EnigmailTb60Compat.generateQI([Ci.nsIStreamListener, Ci.nsIRequestObserver]),
-
- // nsIRequestObserver
- onStartRequest: function(aRequest) {},
- onStopRequest: function(aRequest, aStatusCode) {
- try {
- k(this._data);
- }
- catch (e) {
- EnigmailLog.DEBUG("autoSetup.jsm: createStreamListener: error: " + e + "\n");
- }
- },
-
- // nsIStreamListener
- onDataAvailable: function(aRequest, aInputStream, aOffset, aCount) {
- if (this._stream === null) {
- this._stream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream);
- this._stream.init(aInputStream);
- }
- this._data += this._stream.read(aCount);
- }
- };
-}
-
/**
* Recusrively go through all folders to get a flat array of all sub-folders
* starting with a parent folder.
@@ -474,7 +446,7 @@ function getMsgFolders(folder, msgFolderArr) {
// Util Function for Extracting manually added Headers
function streamListener(callback) {
- var newStreamListener = {
+ let streamListener = {
mAttachments: [],
mHeaders: [],
mBusy: true,
@@ -534,7 +506,7 @@ function streamListener(callback) {
}
};
- return newStreamListener;
+ return streamListener;
}
function getStreamedMessage(msgFolder, msgHeader) {
@@ -624,7 +596,7 @@ function getStreamedHeaders(msgURI, mms) {
let headers = Cc["@mozilla.org/messenger/mimeheaders;1"].createInstance(Ci.nsIMimeHeaders);
let headerObj = {};
try {
- mms.streamHeaders(msgURI, createStreamListener(aRawString => {
+ mms.streamHeaders(msgURI, EnigmailStreams.newStringStreamListener(aRawString => {
try {
//EnigmailLog.DEBUG(`getStreamedHeaders: ${aRawString}\n`);
headers.initialize(aRawString);
diff --git a/package/install.rdf b/package/install.rdf
index d9c57d7a..0e84877a 100644
--- a/package/install.rdf
+++ b/package/install.rdf
@@ -15,7 +15,7 @@
<!-- Thunderbird -->
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
- <em:minVersion>67.0</em:minVersion>
+ <em:minVersion>63.0</em:minVersion>
<em:maxVersion>68.*</em:maxVersion>
</Description>
</em:targetApplication>
diff --git a/package/mimeDecrypt.jsm b/package/mimeDecrypt.jsm
index dc02a29b..8543d6af 100644
--- a/package/mimeDecrypt.jsm
+++ b/package/mimeDecrypt.jsm
@@ -28,6 +28,7 @@ const EnigmailSingletons = ChromeUtils.import("chrome://enigmail/content/modules
const EnigmailHttpProxy = ChromeUtils.import("chrome://enigmail/content/modules/httpProxy.jsm").EnigmailHttpProxy;
const EnigmailCryptoAPI = ChromeUtils.import("chrome://enigmail/content/modules/cryptoAPI.jsm").EnigmailCryptoAPI;
const EnigmailAutocrypt = ChromeUtils.import("chrome://enigmail/content/modules/autocrypt.jsm").EnigmailAutocrypt;
+const EnigmailTb60Compat = ChromeUtils.import("chrome://enigmail/content/modules/tb60compat.jsm").EnigmailTb60Compat;
const APPSHELL_MEDIATOR_CONTRACTID = "@mozilla.org/appshell/window-mediator;1";
const PGPMIME_JS_DECRYPTOR_CONTRACTID = "@mozilla.org/mime/pgp-mime-js-decrypt;1";
@@ -99,8 +100,7 @@ Content-Type: text/html
if (dbHdr.author) msg += `From: ${dbHdr.author}\r\n`;
if (dbHdr.recipients) msg += `To: ${dbHdr.recipients}\r\n`;
if (dbHdr.ccList) msg += `Cc: ${dbHdr.ccList}\r\n`;
- }
- catch (x) {}
+ } catch (x) {}
}
return msg;
@@ -139,12 +139,18 @@ function MimeDecryptHandler() {
this.mimePartNumber = "";
this.dataIsBase64 = null;
this.base64Cache = "";
+
+ if (EnigmailTb60Compat.isMessageUriInPgpMime()) {
+ this.onDataAvailable = this.onDataAvailable68;
+ } else {
+ this.onDataAvailable = this.onDataAvailable60;
+ }
}
MimeDecryptHandler.prototype = {
inStream: Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream),
- onStartRequest: function(request) {
+ onStartRequest: function(request, uri) {
if (!EnigmailCore.getService()) // Ensure Enigmail is initialized
return;
EnigmailLog.DEBUG("mimeDecrypt.jsm: onStartRequest\n"); // always log this one
@@ -159,14 +165,18 @@ MimeDecryptHandler.prototype = {
this.mimeSvc = request.QueryInterface(Ci.nsIPgpMimeProxy);
if ("mimePart" in this.mimeSvc) {
this.mimePartNumber = this.mimeSvc.mimePart;
- }
- else {
+ } else {
this.mimePartNumber = "";
}
if ("messageURI" in this.mimeSvc) {
this.uri = this.mimeSvc.messageURI;
EnigmailLog.DEBUG("mimeDecrypt.jsm: onStartRequest: uri='" + this.uri.spec + "'\n");
+ } else {
+ if (uri) {
+ this.uri = uri.QueryInterface(Ci.nsIURI);
+ EnigmailLog.DEBUG("mimeDecrypt.jsm: onStartRequest: uri='" + this.uri.spec + "'\n");
+ }
}
this.pipe = null;
this.closePipe = false;
@@ -213,35 +223,35 @@ MimeDecryptHandler.prototype = {
// end of Mime-part headers reached
this.headerMode = 2;
return;
- }
- else {
+ } else {
if (data.search(/^content-transfer-encoding:\s*/i) >= 0) {
// extract content-transfer-encoding
data = data.replace(/^content-transfer-encoding:\s*/i, "");
data = data.replace(/;.*/, "").toLowerCase().trim();
if (data.search(/base64/i) >= 0) {
this.xferEncoding = ENCODING_BASE64;
- }
- else if (data.search(/quoted-printable/i) >= 0) {
+ } else if (data.search(/quoted-printable/i) >= 0) {
this.xferEncoding = ENCODING_QP;
}
}
}
- }
- else {
+ } else {
// PGP/MIME main part body
if (this.xferEncoding == ENCODING_QP) {
this.cacheData(EnigmailData.decodeQuotedPrintable(data));
- }
- else {
+ } else {
this.cacheData(data);
}
}
}
},
- onDataAvailable: function(req, stream, offset, count) {
+ /**
+ * onDataAvailable for TB <= 66
+ */
+ onDataAvailable60: function(req, dummy, stream, offset, count) {
+
// get data from libmime
if (!this.initOk) return;
this.inStream.init(stream);
@@ -262,11 +272,42 @@ MimeDecryptHandler.prototype = {
for (let i = 0; i < lines.length; i++) {
this.processData(lines[i] + "\r\n");
}
- }
- else
+ } else
this.processData(data);
+ } else {
+ this.base64Cache += data;
+ }
+ }
+ },
+
+ /**
+ * onDataAvailable for TB >= 68
+ */
+ onDataAvailable68: function(req, stream, offset, count) {
+
+ // get data from libmime
+ if (!this.initOk) return;
+ this.inStream.init(stream);
+
+ if (count > 0) {
+ var data = this.inStream.read(count);
+
+ if (this.mimePartCount == 0 && this.dataIsBase64 === null) {
+ // try to determine if this could be a base64 encoded message part
+ this.dataIsBase64 = this.isBase64Encoding(data);
}
- else {
+
+ if (!this.dataIsBase64) {
+ if (data.search(/[\r\n][^\r\n]+[\r\n]/) >= 0) {
+ // process multi-line data line by line
+ let lines = data.replace(/\r\n/g, "\n").split(/\n/);
+
+ for (let i = 0; i < lines.length; i++) {
+ this.processData(lines[i] + "\r\n");
+ }
+ } else
+ this.processData(data);
+ } else {
this.base64Cache += data;
}
}
@@ -287,8 +328,7 @@ MimeDecryptHandler.prototype = {
let s = atob(str);
// if the conversion succeds, we have a base64 encoded message
ret = true;
- }
- catch (ex) {
+ } catch (ex) {
// not a base64 encoded
}
}
@@ -309,8 +349,7 @@ MimeDecryptHandler.prototype = {
try {
this.base64Cache = EnigmailData.decodeBase64(this.base64Cache);
- }
- catch (ex) {
+ } catch (ex) {
// if decoding failed, try non-encoded version
}
@@ -347,7 +386,7 @@ MimeDecryptHandler.prototype = {
return (this.uri.spec.search(/[&?]header=enigmailConvert/) >= 0);
},
- onStopRequest: function(request, status) {
+ onStopRequest: function(request, status, dummy) {
LOCAL_DEBUG("mimeDecrypt.jsm: onStopRequest\n");
--gNumProc;
if (!this.initOk) return;
@@ -381,8 +420,7 @@ MimeDecryptHandler.prototype = {
let msgSvc = messenger.messageServiceFromURI(EnigmailVerify.getManualUri());
msgSvc.GetUrlForUri(EnigmailVerify.getManualUri(), manUrl, null);
- }
- else {
+ } else {
manUrl.value = {
spec: "enigmail://invalid/message"
};
@@ -425,8 +463,7 @@ MimeDecryptHandler.prototype = {
if (url.value.host !== this.uri.host ||
url.value.path !== this.uri.path)
return;
- }
- else {
+ } else {
// TB >= 57
if (url.value.host !== this.uri.host ||
url.value.pathQueryRef !== this.uri.pathQueryRef)
@@ -434,8 +471,7 @@ MimeDecryptHandler.prototype = {
}
}
}
- }
- catch (ex) {
+ } catch (ex) {
EnigmailLog.writeException("mimeDecrypt.js", ex);
EnigmailLog.DEBUG("mimeDecrypt.jsm: error while processing " + this.msgUriSpec + "\n");
}
@@ -447,8 +483,7 @@ MimeDecryptHandler.prototype = {
if (!EnigmailMime.isRegularMimeStructure(this.mimePartNumber, spec, false)) {
if (!this.isUrlEnigmailConvert()) {
this.returnData(EnigmailMimeDecrypt.emptyAttachment());
- }
- else {
+ } else {
throw "mimeDecrypt.jsm: Cannot decrypt messages with mixed (encrypted/non-encrypted) content";
}
return;
@@ -513,8 +548,7 @@ MimeDecryptHandler.prototype = {
LAST_MSG.lastStatus = this.returnStatus;
LAST_MSG.lastStatus.decryptedHeaders = this.decryptedHeaders;
LAST_MSG.lastStatus.mimePartNumber = this.mimePartNumber;
- }
- else {
+ } else {
LAST_MSG.lastMessageURI = null;
LAST_MSG.lastMessageData = "";
}
@@ -522,8 +556,7 @@ MimeDecryptHandler.prototype = {
this.decryptedData = "";
EnigmailLog.DEBUG("mimeDecrypt.jsm: onStopRequest: process terminated\n"); // always log this one
this.proc = null;
- }
- else {
+ } else {
this.returnStatus = LAST_MSG.lastStatus;
this.decryptedHeaders = LAST_MSG.lastStatus.decryptedHeaders;
this.mimePartNumber = LAST_MSG.lastStatus.mimePartNumber;
@@ -563,13 +596,11 @@ MimeDecryptHandler.prototype = {
encryptedTo: this.returnStatus.encToDetails
}),
this.mimePartNumber);
- }
- else {
+ } else {
this.updateHeadersInMsgDb();
}
this.statusDisplayed = true;
- }
- catch (ex) {
+ } catch (ex) {
EnigmailLog.writeException("mimeDecrypt.jsm", ex);
}
LOCAL_DEBUG("mimeDecrypt.jsm: displayStatus done\n");
@@ -589,8 +620,7 @@ MimeDecryptHandler.prototype = {
try {
this.extractEncryptedHeaders();
this.extractAutocryptGossip();
- }
- catch (ex) {}
+ } catch (ex) {}
let i = this.decryptedData.search(/\n\r?\n/);
if (i > 0) {
@@ -650,21 +680,19 @@ MimeDecryptHandler.prototype = {
veri.onStartRequest(this.mimeSvc, this.uri);
veri.onTextData(data);
veri.onStopRequest(null, 0);
- }
- else {
+ } else {
if ("outputDecryptedData" in this.mimeSvc) {
+ // TB >= 57
this.mimeSvc.outputDecryptedData(data, data.length);
- }
- else {
+ } else {
let gConv = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
gConv.setData(data, data.length);
- this.mimeSvc.onStartRequest(null);
- this.mimeSvc.onDataAvailable(null, gConv, 0, data.length);
- this.mimeSvc.onStopRequest(null, 0);
+ this.mimeSvc.onStartRequest(null, null);
+ this.mimeSvc.onDataAvailable(null, null, gConv, 0, data.length);
+ this.mimeSvc.onStopRequest(null, null, 0);
}
}
- }
- catch (ex) {
+ } catch (ex) {
EnigmailLog.ERROR("mimeDecrypt.jsm: returnData(): mimeSvc.onDataAvailable failed:\n" + ex.toString());
}
},
@@ -688,8 +716,7 @@ MimeDecryptHandler.prototype = {
null,
"");
}
- }
- catch (ex) {}
+ } catch (ex) {}
return 0;
},
@@ -702,8 +729,7 @@ MimeDecryptHandler.prototype = {
try {
let msgDbHdr = this.uri.QueryInterface(Ci.nsIMsgMessageUrl).messageHeader;
msgDbHdr.subject = EnigmailData.convertFromUnicode(this.decryptedHeaders.subject, "utf-8");
- }
- catch (x) {}
+ } catch (x) {}
}
},
@@ -729,8 +755,7 @@ MimeDecryptHandler.prototype = {
let msgDate = null;
try {
msgDate = this.uri.QueryInterface(Ci.nsIMsgMessageUrl).messageHeader.dateInSeconds;
- }
- catch (x) {}
+ } catch (x) {}
for (let i in gossip) {
@@ -738,8 +763,7 @@ MimeDecryptHandler.prototype = {
try {
let r = await EnigmailAutocrypt.processAutocryptHeader(addr, [gossip[i].replace(/ /g, "")], msgDate, true, true);
EnigmailLog.DEBUG(`mimeDecrypt.jsm: extractAutocryptGossip: r=${r}\n`);
- }
- catch (x) {
+ } catch (x) {
EnigmailLog.DEBUG(`mimeDecrypt.jsm: extractAutocryptGossip: Error: ${x}\n`);
}
}
@@ -762,4 +786,4 @@ function initModule() {
if (matches && (matches.length > 1)) {
gDebugLogLevel = matches[1];
}
-}
+} \ No newline at end of file
diff --git a/package/mimeEncrypt.jsm b/package/mimeEncrypt.jsm
index 528e09fa..496829ba 100644
--- a/package/mimeEncrypt.jsm
+++ b/package/mimeEncrypt.jsm
@@ -59,6 +59,12 @@ function PgpMimeEncrypt(sMimeSecurityInfo) {
this.originalSubject = null;
this.keyMap = {};
+ if (EnigmailTb60Compat.isMessageUriInPgpMime()) {
+ this.onDataAvailable = this.onDataAvailable68;
+ } else {
+ this.onDataAvailable = this.onDataAvailable60;
+ }
+
try {
if (sMimeSecurityInfo) {
if ("nsIMsgSMIMECompFields" in Ci) {
@@ -129,7 +135,21 @@ PgpMimeEncrypt.prototype = {
this.encHeader = null;
},
- onDataAvailable: function(req, stream, offset, count) {
+ /**
+ * onDataAvailable for TB <= 66
+ */
+ onDataAvailable60: function(req, ctxt, stream, offset, count) {
+ LOCAL_DEBUG("mimeEncrypt.js: onDataAvailable\n");
+ this.inStream.init(stream);
+ var data = this.inStream.read(count);
+ //LOCAL_DEBUG("mimeEncrypt.js: >"+data+"<\n");
+
+ },
+
+ /**
+ * onDataAvailable for TB >= 67
+ */
+ onDataAvailable68: function(req, stream, offset, count) {
LOCAL_DEBUG("mimeEncrypt.js: onDataAvailable\n");
this.inStream.init(stream);
var data = this.inStream.read(count);
diff --git a/package/mimeVerify.jsm b/package/mimeVerify.jsm
index 2595571a..80d294c4 100644
--- a/package/mimeVerify.jsm
+++ b/package/mimeVerify.jsm
@@ -43,6 +43,12 @@ function MimeVerify(protocol) {
this.partiallySigned = false;
this.exitCode = null;
this.inStream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream);
+
+ if (EnigmailTb60Compat.isMessageUriInPgpMime()) {
+ this.onDataAvailable = this.onDataAvailable68;
+ } else {
+ this.onDataAvailable = this.onDataAvailable60;
+ }
}
@@ -171,23 +177,28 @@ MimeVerify.prototype = {
hdr.micalg = hdr.micalg || "";
this.boundary = hdr.boundary.replace(/['"]/g, "");
}
-
},
onStartRequest: function(request, uri) {
EnigmailLog.DEBUG("mimeVerify.jsm: onStartRequest\n"); // always log this one
- this.uri = uri ? uri.QueryInterface(Ci.nsIURI) : null;
this.mimeSvc = request.QueryInterface(Ci.nsIPgpMimeProxy);
this.msgUriSpec = EnigmailVerify.lastMsgUri;
if ("mimePart" in this.mimeSvc) {
this.mimePartNumber = this.mimeSvc.mimePart;
- }
- else {
+ } else {
this.mimePartNumber = "";
}
+ if ("messageURI" in this.mimeSvc) {
+ this.uri = this.mimeSvc.messageURI;
+ } else {
+ if (uri) {
+ this.uri = uri.QueryInterface(Ci.nsIURI);
+ }
+ }
+
this.dataCount = 0;
this.foundMsg = false;
this.backgroundJob = false;
@@ -207,8 +218,23 @@ MimeVerify.prototype = {
this.parseContentType();
},
- onDataAvailable: function(req, stream, offset, count) {
- LOCAL_DEBUG("mimeVerify.jsm: onDataAvailable: " + count + "\n");
+ /**
+ * onDataAvailable for TB <= 66
+ */
+ onDataAvailable60: function(req, ctxt, stream, offset, count) {
+ LOCAL_DEBUG("mimeVerify.jsm: onDataAvailable60: " + count + "\n");
+ if (count > 0) {
+ this.inStream.init(stream);
+ var data = this.inStream.read(count);
+ this.onTextData(data);
+ }
+ },
+
+ /**
+ * onDataAvailable for TB >= 67
+ */
+ onDataAvailable68: function(req, stream, offset, count) {
+ LOCAL_DEBUG("mimeVerify.jsm: onDataAvailable68: " + count + "\n");
if (count > 0) {
this.inStream.init(stream);
var data = this.inStream.read(count);
@@ -229,8 +255,7 @@ MimeVerify.prototype = {
i += 2 + this.boundary.length;
if (this.keepData[i] == "\n") {
++i;
- }
- else if (this.keepData[i] == "\r") {
+ } else if (this.keepData[i] == "\r") {
++i;
if (this.keepData[i] == "\n") ++i;
}
@@ -238,8 +263,7 @@ MimeVerify.prototype = {
this.keepData = this.keepData.substr(i);
data = this.keepData;
this.readMode = 1;
- }
- else {
+ } else {
this.keepData = data.substr(-this.boundary.length - 3);
}
}
@@ -258,8 +282,7 @@ MimeVerify.prototype = {
this.keepData = this.keepData.substr(i);
this.readMode = 2;
}
- }
- else
+ } else
return;
}
@@ -282,8 +305,7 @@ MimeVerify.prototype = {
if (xferEnc.search(/base64/i) >= 0) {
let bound = this.getBodyPart();
this.keepData = EnigmailData.decodeBase64(this.keepData.substring(bound.start, bound.end)) + "\n";
- }
- else if (xferEnc.search(/quoted-printable/i) >= 0) {
+ } else if (xferEnc.search(/quoted-printable/i) >= 0) {
let bound = this.getBodyPart();
let qp = this.keepData.substring(bound.start, bound.end);
this.keepData = EnigmailData.decodeQuotedPrintable(qp) + "\n";
@@ -293,8 +315,7 @@ MimeVerify.prototype = {
let s = Math.max(this.keepData.search(/^-----BEGIN PGP /m), 0);
let e = Math.max(this.keepData.search(/^-----END PGP /m), this.keepData.length - 30);
this.sigData = this.keepData.substring(s, e + 30);
- }
- else {
+ } else {
this.sigData = "";
}
@@ -385,8 +406,7 @@ MimeVerify.prototype = {
if (this.protectedHeaders && this.protectedHeaders.startPos >= 0 && this.protectedHeaders.endPos > this.protectedHeaders.startPos) {
let r = this.signedData.substr(0, this.protectedHeaders.startPos) + this.signedData.substr(this.protectedHeaders.endPos);
this.returnData(r);
- }
- else {
+ } else {
this.returnData(this.signedData);
}
@@ -410,8 +430,7 @@ MimeVerify.prototype = {
let msgSvc = messenger.messageServiceFromURI(EnigmailVerify.getManualUri());
msgSvc.GetUrlForUri(EnigmailVerify.getManualUri(), manUrl, null);
- }
- else {
+ } else {
manUrl.value = {
spec: "enigmail://invalid/message"
};
@@ -447,8 +466,7 @@ MimeVerify.prototype = {
if (url.value.host !== this.uri.host ||
url.value.path !== this.uri.path)
return;
- }
- else {
+ } else {
// TB >= 57
if (url.value.host !== this.uri.host ||
url.value.pathQueryRef !== this.uri.pathQueryRef)
@@ -456,8 +474,7 @@ MimeVerify.prototype = {
}
}
}
- }
- catch (ex) {
+ } catch (ex) {
EnigmailLog.writeException("mimeVerify.jsm", ex);
EnigmailLog.DEBUG("mimeVerify.jsm: error while processing " + this.msgUriSpec + "\n");
}
@@ -516,17 +533,16 @@ MimeVerify.prototype = {
}
if ("outputDecryptedData" in this.mimeSvc) {
+ // TB >= 57
this.mimeSvc.outputDecryptedData(data, data.length);
- }
- else {
+ } else {
let gConv = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
gConv.setData(data, data.length);
try {
- this.mimeSvc.onStartRequest(null);
- this.mimeSvc.onDataAvailable(null, gConv, 0, data.length);
- this.mimeSvc.onStopRequest(null, 0);
- }
- catch (ex) {
+ this.mimeSvc.onStartRequest(null, null);
+ this.mimeSvc.onDataAvailable(null, null, gConv, 0, data.length);
+ this.mimeSvc.onStopRequest(null, null, 0);
+ } catch (ex) {
EnigmailLog.ERROR("mimeVerify.jsm: returnData(): mimeSvc.onDataAvailable failed:\n" + ex.toString());
}
}
@@ -570,8 +586,7 @@ MimeVerify.prototype = {
this.mimePartNumber);
}
this.statusDisplayed = true;
- }
- catch (ex) {
+ } catch (ex) {
EnigmailLog.writeException("mimeVerify.jsm", ex);
}
}
@@ -595,4 +610,4 @@ function initModule() {
}
}
-initModule();
+initModule(); \ No newline at end of file
diff --git a/package/pEpDecrypt.jsm b/package/pEpDecrypt.jsm
index 12e30e05..222371ac 100644
--- a/package/pEpDecrypt.jsm
+++ b/package/pEpDecrypt.jsm
@@ -25,6 +25,7 @@ const jsmime = ChromeUtils.import("resource:///modules/jsmime.jsm").jsmime;
const EnigmailSingletons = ChromeUtils.import("chrome://enigmail/content/modules/singletons.jsm").EnigmailSingletons;
const EnigmailFuncs = ChromeUtils.import("chrome://enigmail/content/modules/funcs.jsm").EnigmailFuncs;
const EnigmailMimeDecrypt = ChromeUtils.import("chrome://enigmail/content/modules/mimeDecrypt.jsm").EnigmailMimeDecrypt;
+const EnigmailTb60Compat = ChromeUtils.import("chrome://enigmail/content/modules/tb60compat.jsm").EnigmailTb60Compat;
var EXPORTED_SYMBOLS = ["EnigmailPEPDecrypt"];
@@ -186,17 +187,29 @@ function PEPDecryptor(contentType) {
this.mimePartNumber = "";
this.requestingSubpart = false;
this.ignoreMessage = false;
+
+ if (EnigmailTb60Compat.isMessageUriInPgpMime()) {
+ this.onDataAvailable = this.onDataAvailable68;
+ } else {
+ this.onDataAvailable = this.onDataAvailable60;
+ }
}
PEPDecryptor.prototype = {
- onStartRequest: function(request) {
+ onStartRequest: function(request, uri) {
EnigmailLog.DEBUG("pEpDecrypt.jsm: onStartRequest\n");
this.mimeSvc = request.QueryInterface(Ci.nsIPgpMimeProxy);
this.msgWindow = EnigmailVerify.lastMsgWindow;
if ("messageURI" in this.mimeSvc) {
this.uri = this.mimeSvc.messageURI;
+ }
+ else if (uri) {
+ this.uri = uri.QueryInterface(Ci.nsIURI);
+ }
+
+ if (this.uri) {
EnigmailLog.DEBUG("pEpDecrypt.jsm: onStartRequest: uri='" + this.uri.spec + "'\n");
this.backgroundJob = (this.uri.spec.search(/[&?]header=(filter|print|quotebody|enigmailConvert)/) >= 0);
@@ -217,7 +230,20 @@ PEPDecryptor.prototype = {
}
},
- onDataAvailable: function(req, stream, offset, count) {
+ /**
+ * onDataAvailable for TB <= 66
+ */
+ onDataAvailable60: function(req, ctxt, stream, offset, count) {
+ if (count > 0) {
+ inStream.init(stream);
+ this.sourceData += inStream.read(count);
+ }
+ },
+
+ /**
+ * onDataAvailable for TB >= 68
+ */
+ onDataAvailable68: function(req, stream, offset, count) {
if (count > 0) {
inStream.init(stream);
this.sourceData += inStream.read(count);
@@ -368,6 +394,7 @@ PEPDecryptor.prototype = {
returnData: function() {
if ("outputDecryptedData" in this.mimeSvc) {
+ // TB >= 57
this.mimeSvc.outputDecryptedData(this.decryptedData, this.decryptedData.length);
}
else {
diff --git a/package/pgpmimeHandler.jsm b/package/pgpmimeHandler.jsm
index 3f112c84..2e6750bd 100644
--- a/package/pgpmimeHandler.jsm
+++ b/package/pgpmimeHandler.jsm
@@ -73,10 +73,10 @@ function UnknownProtoHandler() {
}
UnknownProtoHandler.prototype = {
- onStartRequest: function(request) {
+ onStartRequest: function(request, ctxt) {
this.mimeSvc = request.QueryInterface(Ci.nsIPgpMimeProxy);
if (!("outputDecryptedData" in this.mimeSvc)) {
- this.mimeSvc.onStartRequest(null);
+ this.mimeSvc.onStartRequest(null, ctxt);
}
this.bound = EnigmailMime.getBoundary(this.mimeSvc.contentType);
/*
@@ -88,7 +88,16 @@ UnknownProtoHandler.prototype = {
this.readMode = 0;
},
- onDataAvailable: function(req, stream, offset, count) {
+ onDataAvailable: function(p1, p2, p3, p4) {
+ if (EnigmailTb60Compat.isMessageUriInPgpMime()) {
+ this.processData(p1, p2, p3, p4);
+ }
+ else {
+ this.processData(p1, null, p2, p3, p4);
+ }
+ },
+
+ processData: function (req, stream, offset, count) {
if (count > 0) {
inStream.init(stream);
let data = inStream.read(count);
@@ -118,11 +127,12 @@ UnknownProtoHandler.prototype = {
let out = l.slice(startIndex, endIndex).join("\n") + "\n";
if ("outputDecryptedData" in this.mimeSvc) {
+ // TB >= 57
this.mimeSvc.outputDecryptedData(out, out.length);
}
else {
gConv.setData(out, out.length);
- this.mimeSvc.onDataAvailable(null, gConv, 0, out.length);
+ this.mimeSvc.onDataAvailable(null, null, gConv, 0, out.length);
}
}
}
@@ -149,7 +159,7 @@ PgpMimeHandler.prototype = {
QueryInterface: EnigmailTb60Compat.generateQI([Ci.nsIStreamListener]),
inStream: Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream),
- onStartRequest: function(request) {
+ onStartRequest: function(request, ctxt) {
let mimeSvc = request.QueryInterface(Ci.nsIPgpMimeProxy);
let ct = mimeSvc.contentType;
@@ -157,6 +167,9 @@ PgpMimeHandler.prototype = {
if ("messageURI" in mimeSvc) {
uri = mimeSvc.messageURI;
}
+ else {
+ uri = ctxt;
+ }
if (!EnigmailCore.getService()) {
// Ensure Enigmail is initialized
diff --git a/package/socks5Proxy.jsm b/package/socks5Proxy.jsm
index 029cbc1e..f84f7962 100644
--- a/package/socks5Proxy.jsm
+++ b/package/socks5Proxy.jsm
@@ -11,9 +11,6 @@ const EXPORTED_SYMBOLS = ["EnigmailSocks5Proxy"];
const CC = Components.Constructor;
-
-
-
const EnigmailTb60Compat = ChromeUtils.import("chrome://enigmail/content/modules/tb60compat.jsm").EnigmailTb60Compat;
const EnigmailLog = ChromeUtils.import("chrome://enigmail/content/modules/log.jsm").EnigmailLog;
const EnigmailLazy = ChromeUtils.import("chrome://enigmail/content/modules/lazy.jsm").EnigmailLazy;
@@ -42,17 +39,27 @@ function createScriptableInputStream(inputStream) {
function buildListener(hasFoundTor, isDoneChecking) {
EnigmailLog.DEBUG("socks5proxy.jsm: buildListener()\n");
- const listener = {
+ let listener = {
onStartRequest: function(request) {},
onStopRequest: function(request, statusCode) {
isDoneChecking();
},
- onDataAvailable: function(request, inputStream, offset, count) {
- const response = createScriptableInputStream(inputStream).read(count);
- hasFoundTor(response.indexOf(EXPECTED_TOR_EXISTS_RESPONSE) !== -1);
- },
QueryInterface: EnigmailTb60Compat.generateQI(["nsIRequestObserver", "nsIStreamListener"])
};
+
+ if (EnigmailTb60Compat.isMessageUriInPgpMime()) {
+ // TB >= 67
+ listener.onDataAvailable = function(request, inputStream, offset, count) {
+ const response = createScriptableInputStream(inputStream).read(count);
+ hasFoundTor(response.indexOf(EXPECTED_TOR_EXISTS_RESPONSE) !== -1);
+ };
+ } else {
+ listener.onDataAvailable = function(request, ctxt, inputStream, offset, count) {
+ const response = createScriptableInputStream(inputStream).read(count);
+ hasFoundTor(response.indexOf(EXPECTED_TOR_EXISTS_RESPONSE) !== -1);
+ };
+ }
+
return listener;
}
@@ -114,4 +121,4 @@ var EnigmailSocks5Proxy = {
EnigmailLog.DEBUG("socks5proxy.jsm: torIpAddr()\n");
return getEnigmailPrefs().getPref(TOR_IP_ADDR_PREF);
}
-};
+}; \ No newline at end of file
diff --git a/package/streams.jsm b/package/streams.jsm
index 681d1b08..777eeb2a 100644
--- a/package/streams.jsm
+++ b/package/streams.jsm
@@ -80,7 +80,7 @@ var EnigmailStreams = {
newStringStreamListener: function(onStopCallback) {
EnigmailLog.DEBUG("enigmailCommon.jsm: newStreamListener\n");
- return {
+ let listener = {
data: "",
inStream: Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream),
_onStopCallback: onStopCallback,
@@ -99,15 +99,26 @@ var EnigmailStreams = {
EnigmailTimer.setTimeout(function _cb() {
cbFunc(cbData);
});
- },
+ }
+ };
- onDataAvailable: function(req, stream, offset, count) {
- // get data from stream
+ if (EnigmailTb60Compat.isMessageUriInPgpMime()) {
+ // TB >= 67
+ listener.onDataAvailable = function(req, stream, offset, count) {
// EnigmailLog.DEBUG("enigmailCommon.jsm: stringListener.onDataAvailable: "+count+"\n");
this.inStream.setInputStream(stream);
this.data += this.inStream.readBytes(count);
- }
- };
+ };
+ }
+ else {
+ listener.onDataAvailable = function(req, ctxt, stream, offset, count) {
+ // EnigmailLog.DEBUG("enigmailCommon.jsm: stringListener.onDataAvailable: "+count+"\n");
+ this.inStream.setInputStream(stream);
+ this.data += this.inStream.readBytes(count);
+ };
+ }
+
+ return listener;
},
/**
diff --git a/package/tb60compat.jsm b/package/tb60compat.jsm
index 65836f2c..73e5a9a7 100644
--- a/package/tb60compat.jsm
+++ b/package/tb60compat.jsm
@@ -12,7 +12,7 @@ var EXPORTED_SYMBOLS = ["EnigmailTb60Compat"];
const MailUtils = ChromeUtils.import("resource:///modules/MailUtils.jsm").MailUtils;
-var gCompFields;
+var gCompFields, gPgpMimeObj;
var EnigmailTb60Compat = {
generateQI: function(aCid) {
@@ -41,5 +41,13 @@ var EnigmailTb60Compat = {
else {
return MailUtils.getFolderForURI(folderUri, false);
}
+ },
+
+ isMessageUriInPgpMime: function() {
+ if (!gPgpMimeObj) {
+ gPgpMimeObj = Cc["@mozilla.org/mime/pgp-mime-js-decrypt;1"].createInstance(Ci.nsIPgpMimeProxy);
+ }
+
+ return ("messageURI" in gPgpMimeObj);
}
};
diff --git a/package/tests/mimeDecrypt-test.js b/package/tests/mimeDecrypt-test.js
index a5ef42b2..0a6e4f2e 100644
--- a/package/tests/mimeDecrypt-test.js
+++ b/package/tests/mimeDecrypt-test.js
@@ -24,10 +24,10 @@ var overwriteEnigmailMime = {
do_load_module("file://" + do_get_cwd().path + "/testHelper.js");
-testing("mimeDecrypt.jsm"); /* global EnigmailMimeDecrypt: false, EnigmailSingletons: false */
+testing("mimeDecrypt.jsm"); /* global EnigmailMimeDecrypt: false, EnigmailSingletons: false, EnigmailTb60Compat: false */
const EnigmailFiles = component("enigmail/files.jsm").EnigmailFiles;
const EnigmailKeyRing = component("enigmail/keyRing.jsm").EnigmailKeyRing;
-const EnigmailTb60Compat = ChromeUtils.import("chrome://enigmail/content/modules/tb60compat.jsm").EnigmailTb60Compat;
+//const EnigmailTb60Compat = ChromeUtils.import("chrome://enigmail/content/modules/tb60compat.jsm").EnigmailTb60Compat;
test(withTestGpgHome(withEnigmail(function processPgpMimeMsg() {
@@ -95,7 +95,11 @@ test(withTestGpgHome(withEnigmail(function processPgpMimeMsg() {
for (i = 0; i < dataArr.length; i++) {
let s = dataArr[i] + "\r\n";
inputStream.setData(s, s.length);
- dec.onDataAvailable(null, inputStream, 0, s.length);
+ if (EnigmailTb60Compat.isMessageUriInPgpMime()) {
+ // TB >= 67
+ dec.onDataAvailable(null, inputStream, 0, s.length);
+ } else
+ dec.onDataAvailable(null, null, inputStream, 0, s.length);
}
dec.onStopRequest(null, null);
diff --git a/package/wksMimeHandler.jsm b/package/wksMimeHandler.jsm
index 9bacd06b..bc6147a7 100644
--- a/package/wksMimeHandler.jsm
+++ b/package/wksMimeHandler.jsm
@@ -11,10 +11,6 @@ var EXPORTED_SYMBOLS = ["EnigmailWksMimeHandler"];
* Module for handling response messages from OpenPGP Web Key Service
*/
-
-
-
-
const EnigmailTb60Compat = ChromeUtils.import("chrome://enigmail/content/modules/tb60compat.jsm").EnigmailTb60Compat;
const EnigmailVerify = ChromeUtils.import("chrome://enigmail/content/modules/mimeVerify.jsm").EnigmailVerify;
const EnigmailLog = ChromeUtils.import("chrome://enigmail/content/modules/log.jsm").EnigmailLog;
@@ -71,7 +67,7 @@ PgpWkdHandler.prototype = {
QueryInterface: EnigmailTb60Compat.generateQI([Ci.nsIStreamListener]),
- onStartRequest: function(request) {
+ onStartRequest: function(request, ctxt) {
EnigmailLog.DEBUG("wksMimeHandler.jsm: onStartRequest\n"); // always log this one
this.mimeSvc = request.QueryInterface(Ci.nsIPgpMimeProxy);
@@ -79,6 +75,9 @@ PgpWkdHandler.prototype = {
if ("messageURI" in this.mimeSvc) {
uri = this.mimeSvc.messageURI;
}
+ else {
+ uri = ctxt;
+ }
if ("mimePart" in this.mimeSvc) {
this.mimePartNumber = this.mimeSvc.mimePart;
@@ -96,7 +95,13 @@ PgpWkdHandler.prototype = {
},
- onDataAvailable: function(req, stream, offset, count) {
+ onDataAvailable: function(req, dummy, stream, offset, count) {
+ if ("messageURI" in this.mimeSvc) {
+ // TB >= 67
+ stream = dummy;
+ count = offset;
+ }
+
LOCAL_DEBUG("wksMimeHandler.jsm: onDataAvailable: " + count + "\n");
if (count > 0) {
this.inStream.init(stream);
diff --git a/stdlib/msgHdrUtils.jsm b/stdlib/msgHdrUtils.jsm
index b1f23b4e..22054ef4 100644
--- a/stdlib/msgHdrUtils.jsm
+++ b/stdlib/msgHdrUtils.jsm
@@ -376,7 +376,11 @@ function createStreamListener(k) {
},
// nsIStreamListener
- onDataAvailable: function(aRequest, aInputStream, aOffset, aCount) {
+ onDataAvailable: function(aRequest, dummy, aInputStream, aOffset, aCount) {
+ if (isPlatformNewerThan("67")) {
+ aInputStream = dummy;
+ aCount = aOffset;
+ }
if (this._stream == null) {
this._stream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream);
this._stream.init(aInputStream);
@@ -517,3 +521,14 @@ function msgHdrsModifyRaw(aMsgHdrs, aTransformer) {
}), null, null, false, "");
}
}
+
+
+/**
+ * return true, if plafform is newer than or equal a given version
+ */
+function isPlatformNewerThan(requestedVersion) {
+ let vc = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator);
+ let appVer = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo).platformVersion;
+
+ return vc.compare(appVer, requestedVersion) >= 0;
+} \ No newline at end of file
diff --git a/ui/content/enigmailMessengerOverlay.js b/ui/content/enigmailMessengerOverlay.js
index 0523b52e..ead1bab4 100644
--- a/ui/content/enigmailMessengerOverlay.js
+++ b/ui/content/enigmailMessengerOverlay.js
@@ -1822,10 +1822,6 @@ Enigmail.msg = {
this.inStream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream);
},
- onDataAvailable: function(req, stream, offset, count) {
- this.inStream.init(stream);
- this.data += this.inStream.read(count);
- },
onStopRequest: function() {
var start = this.data.indexOf("-----BEGIN PGP");
var end = this.data.indexOf("-----END PGP");
@@ -1854,6 +1850,20 @@ Enigmail.msg = {
}
};
+ if (EnigmailTb60Compat.isMessageUriInPgpMime()) {
+ // TB >= 67
+ listener.onDataAvailable = function(req, stream, offset, count) {
+ this.inStream.init(stream);
+ this.data += this.inStream.read(count);
+ };
+ } else {
+ listener.onDataAvailable = function(req, ctxt, stream, offset, count) {
+ this.inStream.init(stream);
+ this.data += this.inStream.read(count);
+ };
+ }
+
+
msgSvc.streamMessage(msgUriSpec,
listener,
msgWindow,