Commit 96151681 authored by Ola Bini's avatar Ola Bini

Fix inadverent LogLevel issue. Also rename Armor module to

EnigmailArmor.

Contributed by Fan Jiang, Iván Pazmiño, Reinaldo de Souza and Ola Bini.
parent 30e1ca95
......@@ -41,7 +41,7 @@
"use strict";
const EXPORTED_SYMBOLS = [ "Armor" ];
const EXPORTED_SYMBOLS = [ "EnigmailArmor" ];
Components.utils.import("resource://enigmail/log.jsm");
......@@ -84,7 +84,7 @@ function indexOfNewline(str, off, then) {
}
}
const Armor = {
const EnigmailArmor = {
// Locates offsets bracketing PGP armored block in text,
// starting from given offset, and returns block type string.
// beginIndex = offset of first character of block
......@@ -145,7 +145,7 @@ const Armor = {
if (blockType == "UNVERIFIED MESSAGE") {
// Skip any unverified message block
return Armor.locateArmoredBlock(text, endIndex+1, indentStr, beginIndexObj, endIndexObj, indentStrObj);
return EnigmailArmor.locateArmoredBlock(text, endIndex+1, indentStr, beginIndexObj, endIndexObj, indentStrObj);
}
beginIndexObj.value = beginIndex;
......@@ -175,7 +175,7 @@ const Armor = {
var i = 0;
var b;
while (( b = Armor.locateArmoredBlock(text, i, "", beginObj, endObj, {})) !== "") {
while (( b = EnigmailArmor.locateArmoredBlock(text, i, "", beginObj, endObj, {})) !== "") {
blocks.push({
begin: beginObj.value,
end: endObj.value,
......@@ -234,8 +234,8 @@ const Armor = {
},
registerOn: function(target) {
target.locateArmoredBlock = Armor.locateArmoredBlock;
target.locateArmoredBlocks = Armor.locateArmoredBlocks;
target.extractSignaturePart = Armor.extractSignaturePart;
target.locateArmoredBlock = EnigmailArmor.locateArmoredBlock;
target.locateArmoredBlocks = EnigmailArmor.locateArmoredBlocks;
target.extractSignaturePart = EnigmailArmor.extractSignaturePart;
}
};
......@@ -45,7 +45,7 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/AddonManager.jsm"); /*global AddonManager: false */
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); /*global XPCOMUtils: false */
Cu.import("resource://enigmail/log.jsm"); /*global Log: false */
Cu.import("resource://enigmail/armor.jsm"); /*global Armor: false */
Cu.import("resource://enigmail/armor.jsm"); /*global EnigmailArmor: false */
Cu.import("resource://enigmail/locale.jsm"); /*global Locale: false */
Cu.import("resource://enigmail/execution.jsm"); /*global Execution: false */
Cu.import("resource://enigmail/dialog.jsm"); /*global Dialog: false */
......@@ -736,7 +736,7 @@ DecryptMessageIntoFolder.prototype = {
var uiFlags = nsIEnigmail.UI_INTERACTIVE | nsIEnigmail.UI_UNVERIFIED_ENC_OK;
var plaintexts = [];
var blocks = Armor.locateArmoredBlocks(mime.body);
var blocks = EnigmailArmor.locateArmoredBlocks(mime.body);
var tmp = [];
for (let i = 0; i < blocks.length; i++) {
......
/*global Components: false, Data: false, Log: false, Prefs: false, Locale: false, Armor: false, Data: false, Execution: false, Dialog: false */
/*global Components: false, Data: false, Log: false, Prefs: false, Locale: false, EnigmailArmor: false, Data: false, Execution: false, Dialog: false */
/*jshint -W097 */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
......@@ -480,7 +480,7 @@ const Decryption = {
var beginIndexObj = {};
var endIndexObj = {};
var indentStrObj = {};
var blockType = Armor.locateArmoredBlock(cipherText, 0, "", beginIndexObj, endIndexObj, indentStrObj);
var blockType = EnigmailArmor.locateArmoredBlock(cipherText, 0, "", beginIndexObj, endIndexObj, indentStrObj);
if (!blockType || blockType == "SIGNATURE") {
errorMsgObj.value = Locale.getString("noPGPblock");
statusFlagsObj.value |= nsIEnigmail.DISPLAY_MESSAGE;
......@@ -538,7 +538,7 @@ const Decryption = {
var newSignature = "";
if (verifyOnly) {
newSignature = Armor.extractSignaturePart(pgpBlock, nsIEnigmail.SIGNATURE_ARMOR);
newSignature = EnigmailArmor.extractSignaturePart(pgpBlock, nsIEnigmail.SIGNATURE_ARMOR);
if (oldSignature && (newSignature != oldSignature)) {
Log.ERROR("enigmail.js: Enigmail.decryptMessage: Error - signature mismatch "+newSignature+"\n");
errorMsgObj.value = Locale.getString("sigMismatch");
......@@ -641,7 +641,7 @@ const Decryption = {
var innerKeyBlock;
if (verifyOnly) {
// Search for indented public key block in signed message
var innerBlockType = Armor.locateArmoredBlock(pgpBlock, 0, "- ", beginIndexObj, endIndexObj, indentStrObj);
var innerBlockType = EnigmailArmor.locateArmoredBlock(pgpBlock, 0, "- ", beginIndexObj, endIndexObj, indentStrObj);
if (innerBlockType == "PUBLIC KEY BLOCK") {
innerKeyBlock = pgpBlock.substr(beginIndexObj.value,
......
......@@ -53,7 +53,7 @@ Cu.import("resource://enigmail/decryption.jsm"); /*global Decryption: false */
Cu.import("resource://enigmail/enigmailProtocolHandler.jsm"); /*global EnigmailProtocolHandler: false */
Cu.import("resource://enigmail/rules.jsm"); /*global Rules: false */
Cu.import("resource://enigmail/filters.jsm"); /*global Filters: false */
Cu.import("resource://enigmail/armor.jsm"); /*global Armor: false */
Cu.import("resource://enigmail/armor.jsm"); /*global EnigmailArmor: false */
Cu.import("resource://enigmail/log.jsm"); /*global Log: false */
Cu.import("resource://enigmail/os.jsm"); /*global OS: false */
Cu.import("resource://enigmail/locale.jsm"); /*global Locale: false */
......@@ -355,7 +355,7 @@ Enigmail.prototype = {
}; // Enigmail.prototype
Armor.registerOn(Enigmail.prototype);
EnigmailArmor.registerOn(Enigmail.prototype);
Decryption.registerOn(Enigmail.prototype);
Encryption.registerOn(Enigmail.prototype);
Rules.registerOn(Enigmail.prototype);
......
......@@ -55,7 +55,7 @@ Cu.import("resource://enigmail/locale.jsm"); /*global Locale: false */
Cu.import("resource://enigmail/gpg.jsm"); /*global Gpg: false */
Cu.import("resource://enigmail/files.jsm"); /*global Files: false */
Cu.import("resource://enigmail/trust.jsm"); /*global Trust: false */
Cu.import("resource://enigmail/armor.jsm"); /*global Armor: false */
Cu.import("resource://enigmail/armor.jsm"); /*global EnigmailArmor: false */
Cu.import("resource://enigmail/dialog.jsm"); /*global Dialog: false */
Cu.import("resource://enigmail/os.jsm"); /*global OS: false */
Cu.import("resource://enigmail/time.jsm"); /*global Time: false */
......@@ -589,7 +589,7 @@ const KeyRing = {
const beginIndexObj = {};
const endIndexObj = {};
const blockType = Armor.locateArmoredBlock(msgText, 0, "", beginIndexObj, endIndexObj, {});
const blockType = EnigmailArmor.locateArmoredBlock(msgText, 0, "", beginIndexObj, endIndexObj, {});
if (!blockType) {
errorMsgObj.value = Locale.getString("noPGPblock");
return 1;
......
......@@ -62,7 +62,7 @@ function initPrefService() {
p.branch = p.service.getBranch(ENIGMAIL_PREFS_ROOT);
if(p.branch.getCharPref("logDirectory")) {
Log.setLogLevel = 5;
Log.setLogLevel(5);
}
}
catch (ex) {
......
......@@ -10,9 +10,9 @@
do_load_module("file://" + do_get_cwd().path + "/testHelper.js");
testing("armor.jsm"); /*global Armor: false */
testing("armor.jsm"); /*global EnigmailArmor: false */
test(function shouldLocateArmoredBlock() {
test(function shouldLocateEnigmailArmoredBlock() {
const text = "" +
" -----BEGIN PGP SIGNATURE-----\n" +
" Version: GnuPG/MacGPG2 v2.0.22 (Darwin)\n" +
......@@ -36,7 +36,7 @@ test(function shouldLocateArmoredBlock() {
const endIndexObj = {};
const indentStrObj = {};
const indentStr = "";
const blockType = Armor.locateArmoredBlock(text, 0, indentStr, beginIndexObj, endIndexObj, indentStrObj);
const blockType = EnigmailArmor.locateArmoredBlock(text, 0, indentStr, beginIndexObj, endIndexObj, indentStrObj);
Assert.equal(0, beginIndexObj.value);
Assert.equal(" ", indentStrObj.value);
Assert.equal("SIGNATURE", blockType);
......@@ -70,9 +70,9 @@ test(function shouldExtractSignaturePart() {
"\n" +
"-----END PGP SIGNATURE-----";
const signature_text = Armor.extractSignaturePart(signature_block, Ci.nsIEnigmail.SIGNATURE_TEXT);
const signature_headers = Armor.extractSignaturePart(signature_block, Ci.nsIEnigmail.SIGNATURE_HEADERS);
const signature_armor = Armor.extractSignaturePart(signature_block, Ci.nsIEnigmail.SIGNATURE_ARMOR);
const signature_text = EnigmailArmor.extractSignaturePart(signature_block, Ci.nsIEnigmail.SIGNATURE_TEXT);
const signature_headers = EnigmailArmor.extractSignaturePart(signature_block, Ci.nsIEnigmail.SIGNATURE_HEADERS);
const signature_armor = EnigmailArmor.extractSignaturePart(signature_block, Ci.nsIEnigmail.SIGNATURE_ARMOR);
Assert.equal(signature.text, signature_text);
Assert.equal(signature.header, signature_headers);
Assert.equal(signature.armor.replace(/\s*/g, ""), signature_armor);
......
......@@ -12,7 +12,7 @@ do_load_module("file://" + do_get_cwd().path + "/testHelper.js"); /*global withE
testing("decryption.jsm"); /*global Decryption: false, nsIEnigmail: false */
component("enigmail/keyRing.jsm"); /*global KeyRing: fales */
component("enigmail/armor.jsm"); /*global Armor: fales */
component("enigmail/armor.jsm"); /*global EnigmailArmor: fales */
test(withTestGpgHome(withEnigmail(function shouldDecryptMessage() {
const secretKey = do_get_file("resources/dev-strike.sec", false);
......@@ -59,6 +59,6 @@ test(withTestGpgHome(withEnigmail(function shouldDecryptMessage() {
Assert.equal(0, errorMsgObj.value);
Assert.equal("Hello there!", decryptResult);
Assert.equal(true, (statusFlagObj.value & (nsIEnigmail.DISPLAY_MESSAGE | nsIEnigmail.DECRYPTION_OKAY)) !== 0);
const blockType = Armor.locateArmoredBlock(encryptResult, 0, "", {}, {}, {});
const blockType = EnigmailArmor.locateArmoredBlock(encryptResult, 0, "", {}, {}, {});
Assert.equal("MESSAGE", blockType);
})));
......@@ -12,7 +12,7 @@ do_load_module("file://" + do_get_cwd().path + "/testHelper.js"); /*global withE
testing("encryption.jsm"); /*global Encryption: false, nsIEnigmail: false */
component("enigmail/keyRing.jsm"); /*global KeyRing: fales */
component("enigmail/armor.jsm"); /*global Armor: fales */
component("enigmail/armor.jsm"); /*global EnigmailArmor: fales */
test(withTestGpgHome(withEnigmail(function shouldSignMessage() {
const secretKey = do_get_file("resources/dev-strike.sec", false);
......@@ -38,7 +38,7 @@ test(withTestGpgHome(withEnigmail(function shouldSignMessage() {
Assert.equal(0, exitCodeObj.value);
Assert.equal(0, errorMsgObj.value);
Assert.equal(true, (statusFlagObj.value == nsIEnigmail.SIG_CREATED));
const blockType = Armor.locateArmoredBlock(encryptResult, 0, "", {}, {}, {});
const blockType = EnigmailArmor.locateArmoredBlock(encryptResult, 0, "", {}, {}, {});
Assert.equal("SIGNED MESSAGE", blockType);
})));
......@@ -66,6 +66,6 @@ test(withTestGpgHome(withEnigmail(function shouldEncryptMessage() {
Assert.equal(0, exitCodeObj.value);
Assert.equal(0, errorMsgObj.value);
Assert.equal(true, (statusFlagObj.value & nsIEnigmail.END_ENCRYPTION) !== 0);
const blockType = Armor.locateArmoredBlock(encryptResult, 0, "", {}, {}, {});
const blockType = EnigmailArmor.locateArmoredBlock(encryptResult, 0, "", {}, {}, {});
Assert.equal("MESSAGE", blockType);
})));
/*global do_load_module: false, do_get_file: false, do_get_cwd: false, testing: false, test: false, Assert: false, resetting: false, JSUnit: false, do_test_pending: false, do_test_finished: false, withTestGpgHome:false */
/*global EnigmailCore: false, Enigmail: false, component: false, Cc: false, Ci: false, withEnvironment: false, nsIEnigmail: false, nsIEnvironment: false, Ec: false, Prefs: false, OS: false, Armor: false */
/*global EnigmailCore: false, Enigmail: false, component: false, Cc: false, Ci: false, withEnvironment: false, nsIEnigmail: false, nsIEnvironment: false, Ec: false, Prefs: false, OS: false, EnigmailArmor: false */
/*jshint -W120 */
/*jshint -W097 */
/*
......
......@@ -3900,7 +3900,7 @@ Enigmail.msg = {
var beginIndexObj = {};
var endIndexObj = {};
var indentStrObj = {};
var blockType = Armor.locateArmoredBlock(docText, 0, indentStr, beginIndexObj, endIndexObj, indentStrObj);
var blockType = EnigmailArmor.locateArmoredBlock(docText, 0, indentStr, beginIndexObj, endIndexObj, indentStrObj);
if ((blockType != "MESSAGE") && (blockType != "SIGNED MESSAGE"))
return;
......@@ -4030,7 +4030,7 @@ Enigmail.msg = {
return;
// Extract text portion of clearsign block
plainText = Armor.extractSignaturePart(pgpBlock, nsIEnigmail.SIGNATURE_TEXT);
plainText = EnigmailArmor.extractSignaturePart(pgpBlock, nsIEnigmail.SIGNATURE_TEXT);
}
var doubleDashSeparator = Prefs.getPref("doubleDashSeparator");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment