From 184caf60112f176d1916e31cba2afbac77d6ac66 Mon Sep 17 00:00:00 2001 From: lieser Date: Fri, 31 May 2013 20:45:15 +0200 Subject: [PATCH] fixed #3 (issue with RSS feeds) --- CHANGELOG.txt | 5 +- chrome/content/dkim.js | 112 ++++++++++++++++++++++++----------------- install.rdf | 2 +- 3 files changed, 70 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 79ae0d5d..3ede5c5a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,6 @@ -0.3.3pre [2013-05-30] ---------------------- +0.3.3 [2013-05-31] +------------------ + - fixed issue with RSS feeds - added debug info to rsasign-1.2.js 0.3.2 [2013-05-30] diff --git a/chrome/content/dkim.js b/chrome/content/dkim.js index 7b8d575d..c41dfeba 100644 --- a/chrome/content/dkim.js +++ b/chrome/content/dkim.js @@ -4,7 +4,7 @@ * Verifies the DKIM-Signatures as specified in RFC 6376 * http://tools.ietf.org/html/rfc6376 * - * version: 0.3.3pre (30 May 2013) + * version: 0.3.3 (31 May 2013) * * Copyright (c) 2013 Philippe Lieser * @@ -234,6 +234,16 @@ DKIM_Verifier.DKIMVerifier = (function() { } else { header += c; } + + // if end of msg is reached before end of header, + // it is no in correct e-mail format + if (inputStream.available() === 0) { + // close inputStream + inputStream.close(); + nsIInputStream.close(); + + throw new DKIM_InternalError("Message is not in correct e-mail format"); + } } // read body @@ -802,6 +812,29 @@ DKIM_Verifier.DKIMVerifier = (function() { return hashInput; } + /* + * handeles Exeption + */ + function handleExeption(e) { + var dkimMsgHdrRes = document.getElementById("dkim_verifier_msgHdrRes"); + + if (e instanceof DKIM_SigError) { + // if domain is testing DKIM, treat msg as not signed + if (e.message === DKIM_STRINGS.DKIM_SIGERROR_KEY_TESTMODE) { + var dkimVerifierBox = document.getElementById("dkim_verifier_msgHdrBox"); + dkimVerifierBox.collapsed = true; + } + + dkimMsgHdrRes.value = DKIM_STRINGS.PERMFAIL + " (" + e.message + ")"; + } else { + dkimMsgHdrRes.value = "Internal Error"; + } + + if (prefDKIMDebug) { + Components.utils.reportError(e+"\n"+e.stack); + } + } + /* * 1. part of verifying the signature * will verify until key query, the rest is in verifySignaturePart2 @@ -830,15 +863,7 @@ DKIM_Verifier.DKIMVerifier = (function() { msg ); } catch(e) { - var dkimMsgHdrRes = document.getElementById("dkim_verifier_msgHdrRes"); - if (e instanceof DKIM_SigError) { - dkimMsgHdrRes.value = DKIM_STRINGS.PERMFAIL + " (" + e.message + ")"; - } else { - dkimMsgHdrRes.value = "Internal Error"; - } - if (prefDKIMDebug) { - Components.utils.reportError(e+"\n"+e.stack); - } + handleExeption(e); } } @@ -920,23 +945,7 @@ DKIM_Verifier.DKIMVerifier = (function() { dkimMsgHdrRes.value = DKIM_STRINGS.SUCCESS(msg.DKIMSignature.d); } catch(e) { - var dkimMsgHdrRes = document.getElementById("dkim_verifier_msgHdrRes"); - - if (e instanceof DKIM_SigError) { - // if domain is testing DKIM, treat msg as not signed - if (e.message === DKIM_STRINGS.DKIM_SIGERROR_KEY_TESTMODE) { - var dkimVerifierBox = document.getElementById("dkim_verifier_msgHdrBox"); - dkimVerifierBox.collapsed = true; - } - - dkimMsgHdrRes.value = DKIM_STRINGS.PERMFAIL + " (" + e.message + ")"; - } else { - dkimMsgHdrRes.value = "Internal Error"; - } - - if (prefDKIMDebug) { - Components.utils.reportError(e+"\n"+e.stack); - } + handleExeption(e); } } @@ -1055,27 +1064,38 @@ var that = { * gets called if a new message ist viewed */ messageLoaded : function () { - // get msg uri - var msgURI = gDBView.URIForFirstSelectedMessage ; - - // parse msg into msg.header and msg.body - var msg = parseMsg(msgURI); - msg.msgURI = msgURI; - - // parse the header - msg.headerFields = parseHeader(msg.headerPlain); + try { + // get msg uri + var msgURI = gDBView.URIForFirstSelectedMessage ; + + // return if msg is in RSS folder + var messageService = messenger.messageServiceFromURI(msgURI); + if (messageService.messageURIToMsgHdr(msgURI).folder.server.type === "rss") { + return; + } + + // parse msg into msg.header and msg.body + var msg = parseMsg(msgURI); + msg.msgURI = msgURI; + + // parse the header + msg.headerFields = parseHeader(msg.headerPlain); - // check if DKIMSignatureHeader exist - if (msg.headerFields["dkim-signature"] === undefined) { - // no signature to check, return - return; + // check if DKIMSignatureHeader exist + if (msg.headerFields["dkim-signature"] === undefined) { + // no signature to check, return + return; + } + + // show the dkim verifier header box + var dkimVerifierBox = document.getElementById("dkim_verifier_msgHdrBox"); + dkimVerifierBox.collapsed = false; + + verifySignaturePart1(msg); + + } catch(e) { + handleExeption(e); } - - // show the dkim verifier header box - var dkimVerifierBox = document.getElementById("dkim_verifier_msgHdrBox"); - dkimVerifierBox.collapsed = false; - - verifySignaturePart1(msg); }, /* diff --git a/install.rdf b/install.rdf index f6535fce..41ca3305 100644 --- a/install.rdf +++ b/install.rdf @@ -10,7 +10,7 @@ DKIM Verifier Verifies the DKIM-Signature of an e-mail. - 0.3.3pre + 0.3.3 Philippe Lieser