Skip to content

Commit

Permalink
fixed #3 (issue with RSS feeds)
Browse files Browse the repository at this point in the history
  • Loading branch information
lieser committed May 31, 2013
1 parent 5127c97 commit 184caf6
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 49 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
112 changes: 66 additions & 46 deletions chrome/content/dkim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
},

/*
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<em:name>DKIM Verifier</em:name>
<em:description>Verifies the DKIM-Signature of an e-mail.</em:description>

<em:version>0.3.3pre</em:version>
<em:version>0.3.3</em:version>

<em:creator>Philippe Lieser</em:creator>

Expand Down

0 comments on commit 184caf6

Please sign in to comment.