mirror of
https://github.com/MailHops/mailhops-plugin.git
synced 2025-05-15 22:00:08 -07:00
Removed duplicate spf block, removed auth image and added update auth bg color
This commit is contained in:
parent
890c3ed74f
commit
151c08bb88
@ -352,39 +352,12 @@ class MailHops {
|
|||||||
|
|
||||||
auth(header_xmailer, header_useragent, header_xmimeole, header_auth, header_spf, header_unsubscribe) {
|
auth(header_xmailer, header_useragent, header_xmimeole, header_auth, header_spf, header_unsubscribe) {
|
||||||
let auth = [];
|
let auth = [];
|
||||||
|
var color = 'green';
|
||||||
//SPF
|
//SPF
|
||||||
if (header_spf) {
|
if (header_spf) {
|
||||||
// Compact whitespace, make sure addresses enclosed in <> parse as valid
|
// Compact whitespace, make sure addresses enclosed in <> parse as valid
|
||||||
// XHTMl later on.
|
// XHTMl later on.
|
||||||
header_spf = this.sanitizeString (header_spf);
|
header_spf = this.sanitizeString (header_spf);
|
||||||
|
|
||||||
// Split value on whitespace. We'll extract data from this.
|
|
||||||
var headerSPFArr = header_spf.split(' ');
|
|
||||||
|
|
||||||
// First element should always indicate the state.
|
|
||||||
var spfState = headerSPFArr.shift ();
|
|
||||||
|
|
||||||
// Additionally, we might have a reason description, enclosed in parenthesis.
|
|
||||||
// Example: spfState = "Pass", reason description: "(mailfrom)"
|
|
||||||
var spfStateReason = '';
|
|
||||||
if (-1 != headerSPFArr[0].search (/^\(.*\)$/)) {
|
|
||||||
spfStateReason = ' ' + headerSPFArr.shift ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put it all together, with extra information if requested.
|
|
||||||
var copy = spfState + spfStateReason;
|
|
||||||
if (this.options.extrainfo) {
|
|
||||||
copy += '\n<br />' + headerSPFArr.join (' ') + '\n<br />';
|
|
||||||
}
|
|
||||||
copy += '\n<br />' + MailHopsUtils.spf(spfState.toLowerCase ()).trim ();
|
|
||||||
|
|
||||||
this.LOG ("SPF state and data: " + copy);
|
|
||||||
auth.push({
|
|
||||||
type: 'SPF',
|
|
||||||
color: 'green',
|
|
||||||
icon: '/images/auth/' + spfState.toLowerCase () + '.png',
|
|
||||||
copy: copy
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
//Authentication-Results
|
//Authentication-Results
|
||||||
//http://tools.ietf.org/html/rfc8601
|
//http://tools.ietf.org/html/rfc8601
|
||||||
@ -393,7 +366,7 @@ class MailHops {
|
|||||||
var headerAuthArr = [];
|
var headerAuthArr = [];
|
||||||
|
|
||||||
// The header might contain multiple lines, so iterate above them.
|
// The header might contain multiple lines, so iterate above them.
|
||||||
var headerAuthArr_ = header_auth.split('\n');
|
var headerAuthArr = header_auth.split('\n');
|
||||||
var dkimState = '';
|
var dkimState = '';
|
||||||
var spfState = '';
|
var spfState = '';
|
||||||
var dkimReason = '';
|
var dkimReason = '';
|
||||||
@ -402,8 +375,8 @@ class MailHops {
|
|||||||
var spfAux = '';
|
var spfAux = '';
|
||||||
var gotDkimState = false;
|
var gotDkimState = false;
|
||||||
var gotSpfState = false;
|
var gotSpfState = false;
|
||||||
for (var i = 0; i < headerAuthArr_.length; ++i) {
|
for (var i = 0; i < headerAuthArr.length; ++i) {
|
||||||
var curLine = headerAuthArr_[i];
|
var curLine = headerAuthArr[i];
|
||||||
this.LOG ('current header line: ' + curLine + '\n');
|
this.LOG ('current header line: ' + curLine + '\n');
|
||||||
|
|
||||||
// This is the actual fun part.
|
// This is the actual fun part.
|
||||||
@ -531,7 +504,6 @@ class MailHops {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gotDkimState) {
|
if (gotDkimState) {
|
||||||
// Just sanitize our data.
|
// Just sanitize our data.
|
||||||
dkimState = this.sanitizeString (dkimState);
|
dkimState = this.sanitizeString (dkimState);
|
||||||
@ -548,9 +520,15 @@ class MailHops {
|
|||||||
copy += '\n<br />\n<br />' + MailHopsUtils.dkim(dkimState).trim();
|
copy += '\n<br />\n<br />' + MailHopsUtils.dkim(dkimState).trim();
|
||||||
|
|
||||||
this.LOG ("DKIM state and data: " + copy);
|
this.LOG ("DKIM state and data: " + copy);
|
||||||
|
color = 'green';
|
||||||
|
if(dkimState.toLowerCase().indexOf('soft') != -1 || dkimState.toLowerCase().indexOf('temperror') != -1){
|
||||||
|
color = 'yellow';
|
||||||
|
} else if(dkimState.toLowerCase().indexOf('fail') != -1 || dkimState.toLowerCase().indexOf('error') != -1){
|
||||||
|
color = 'red';
|
||||||
|
}
|
||||||
auth.push({
|
auth.push({
|
||||||
type: 'DKIM',
|
type: 'DKIM',
|
||||||
color: 'green',
|
color: color,
|
||||||
icon: '/images/auth/' + dkimState.toLowerCase () + '.png',
|
icon: '/images/auth/' + dkimState.toLowerCase () + '.png',
|
||||||
copy: copy
|
copy: copy
|
||||||
});
|
});
|
||||||
@ -569,10 +547,16 @@ class MailHops {
|
|||||||
}
|
}
|
||||||
copy += '\n<br />\n<br />' + MailHopsUtils.spf(spfState).trim();
|
copy += '\n<br />\n<br />' + MailHopsUtils.spf(spfState).trim();
|
||||||
|
|
||||||
|
color = 'green';
|
||||||
|
if(spfState.toLowerCase().indexOf('soft') != -1 || spfState.toLowerCase().indexOf('temperror') != -1){
|
||||||
|
color = 'yellow';
|
||||||
|
} else if(spfState.toLowerCase().indexOf('fail') != -1 || spfState.toLowerCase().indexOf('error') != -1){
|
||||||
|
color = 'red';
|
||||||
|
}
|
||||||
this.LOG ("SPF state and data: " + copy);
|
this.LOG ("SPF state and data: " + copy);
|
||||||
auth.push({
|
auth.push({
|
||||||
type: 'SPF',
|
type: 'SPF',
|
||||||
color: 'green',
|
color: color,
|
||||||
icon: '/images/auth/' + spfState.toLowerCase () + '.png',
|
icon: '/images/auth/' + spfState.toLowerCase () + '.png',
|
||||||
copy: copy
|
copy: copy
|
||||||
});
|
});
|
||||||
|
@ -139,7 +139,7 @@ function updateContent(msg, noauth) {
|
|||||||
if (!noauth && msg.message.auth.length) {
|
if (!noauth && msg.message.auth.length) {
|
||||||
for (var a = 0; a < msg.message.auth.length; a++){
|
for (var a = 0; a < msg.message.auth.length; a++){
|
||||||
if (msg.message.auth[a].icon) {
|
if (msg.message.auth[a].icon) {
|
||||||
var add = '<label class="tiny ui label ' + msg.message.auth[a].color + '"><img src="' + msg.message.auth[a].icon + '"/>' + msg.message.auth[a].type + ' ' + msg.message.auth[a].copy + '</label>';
|
var add = '<div style="padding: 2px;"><label class="tiny ui label ' + msg.message.auth[a].color + '">' + msg.message.auth[a].type + ' ' + msg.message.auth[a].copy + '</label></div>';
|
||||||
if (debug) {
|
if (debug) {
|
||||||
console.log("adding to auth (type icon): '" + add + "'");
|
console.log("adding to auth (type icon): '" + add + "'");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user