Skip to content

Commit

Permalink
2.x: Backport feature detailed results 5 to 2x (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
dodmi authored Jan 5, 2025
1 parent 58ba99e commit f66afba
Show file tree
Hide file tree
Showing 21 changed files with 442 additions and 107 deletions.
59 changes: 57 additions & 2 deletions chrome/content/dkim.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ DKIM_Verifier.Display = (function() {
var expandedFromBox;
var collapsed1LfromBox; // for CompactHeader addon
var collapsed2LfromBox; // for CompactHeader addon
var verifierBox;
var policyAddUserExceptionButton;
var markKeyAsSecureButton;
var updateKeyButton;
Expand All @@ -67,11 +68,35 @@ DKIM_Verifier.Display = (function() {
* Sets the result value for headerTooltips and statusbar panel.
*
* @param {String} value
* @param {String|undefined} [details]
* @return {void}
*/
function setValue(value) {
function setValue(value, details) {
headerTooltips.value = value;
statusbarPanel.value = value;

let emailBox = expandedFromBox ? expandedFromBox.emailAddresses.boxObject.firstChild : undefined;
let emailBoxCH1 = collapsed1LfromBox ? collapsed1LfromBox.emailAddresses.boxObject.firstChild : undefined; // for CompactHeader addon
let emailBoxCH2 = collapsed2LfromBox ? collapsed2LfromBox.emailAddresses.boxObject.firstChild : undefined; // for CompactHeader addon

let showFromToolTip =
(emailBox && emailBox.tooltip === "dkim-verifier-header-tooltip-from")
|| (emailBoxCH1 && emailBoxCH1.tooltip === "dkim-verifier-header-tooltip-from")
|| (emailBoxCH2 && emailBoxCH2.tooltip === "dkim-verifier-header-tooltip-from");

if (details) {
if (showFromToolTip && emailBox) { emailBox.tooltipText = details; }
if (showFromToolTip && emailBoxCH1) { emailBoxCH1.tooltipText = details; }
if (showFromToolTip && emailBoxCH2) { emailBoxCH2.tooltipText = details; }
verifierBox.boxObject.firstChild.tooltipText = details;
statusbarPanel.tooltipText = details;
} else {
if (emailBox) { emailBox.tooltipText = ""; }
if (emailBoxCH1) { emailBoxCH1.tooltipText = ""; }
if (emailBoxCH2) { emailBoxCH2.tooltipText = ""; }
verifierBox.boxObject.firstChild.tooltipText = "";
statusbarPanel.tooltipText = "";
}
}

/**
Expand Down Expand Up @@ -216,7 +241,36 @@ DKIM_Verifier.Display = (function() {
statusbarPanel.dkimStatus = result.dkim[0].result;
that.setCollapsed(result.dkim[0].res_num);
header.value = result.dkim[0].result_str;
setValue(result.dkim[0].result_str);

let sigCount = 0;
let detailsHint;
if (prefs.getBoolPref("advancedInfo.show")) {
detailsHint = "";
if (prefs.getBoolPref("advancedInfo.allSignatures")) {
result.dkim.forEach(dkim => {
if (dkim.details_str) {
detailsHint += "\n----\n" + dkim.details_str;
sigCount += 1;
}
});
if (sigCount === 0) {
// the check resulted in an error, because the signature wasn't well formed
// or there was no signature
detailsHint = undefined;
}
} else {
detailsHint = result.dkim[0].details_str;
}
if (detailsHint) {
// there is extended information to display
let caption = "";
if (prefs.getBoolPref("advancedInfo.allSignatures")) {
caption = dkimStrings.getFormattedString("DKIM_RESULT_DETAILS_SIG_COUNT", [sigCount]);
}
detailsHint = caption + detailsHint;
}
}
setValue(result.dkim[0].result_str, detailsHint);

switch(result.dkim[0].res_num) {
case DKIM_Verifier.AuthVerifier.DKIM_RES.SUCCESS: {
Expand Down Expand Up @@ -405,6 +459,7 @@ var that = {
expandedFromBox = document.getElementById("expandedfromBox");
collapsed1LfromBox = document.getElementById("CompactHeader_collapsed1LfromBox");
collapsed2LfromBox = document.getElementById("CompactHeader_collapsed2LfromBox");
verifierBox = document.getElementById("expandeddkim-verifierBox");
policyAddUserExceptionButton = document.
getElementById("dkim_verifier.policyAddUserException");
markKeyAsSecureButton = document.getElementById("dkim_verifier.markKeyAsSecure");
Expand Down
27 changes: 27 additions & 0 deletions chrome/content/options_display.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// @ts-nocheck
/* eslint-env browser */
/* eslint strict: ["warn", "function"] */
/* exported toggleDetailsOptionsEnabled */

let checkBox = {
showAdvancedInfo : null,
allSignatures : null,
includeHeaders : null
};

function init() {
"use strict";
checkBox.showAdvancedInfo = document.getElementById("display.advancedInfo.show");
checkBox.allSignatures = document.getElementById("display.advancedInfo.allSignatures");
checkBox.includeHeaders = document.getElementById("display.advancedInfo.includeHeaders");
toggleDetailsOptionsEnabled();
}

function toggleDetailsOptionsEnabled() {
"use strict";
let disabled = !checkBox.showAdvancedInfo.checked;
checkBox.allSignatures.disabled = disabled;
checkBox.includeHeaders.disabled = disabled;
}

window.addEventListener("load", init, false);
41 changes: 34 additions & 7 deletions chrome/content/options_display.xul
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<prefpane id="paneDisplay" onpaneload="onLoad('paneDisplay');">
<script type="application/javascript" src="chrome://dkim_verifier/content/options_display.js"/>
<preferences>
<preference id="pref_colorFrom"
name="extensions.dkim_verifier.colorFrom"
Expand All @@ -16,28 +17,28 @@
<preference id="pref_color.success.background"
name="extensions.dkim_verifier.color.success.background"
type="string"/>

<preference id="pref_color.warning.text"
name="extensions.dkim_verifier.color.warning.text"
type="string"/>
<preference id="pref_color.warning.background"
name="extensions.dkim_verifier.color.warning.background"
type="string"/>

<preference id="pref_color.permfail.text"
name="extensions.dkim_verifier.color.permfail.text"
type="string"/>
<preference id="pref_color.permfail.background"
name="extensions.dkim_verifier.color.permfail.background"
type="string"/>

<preference id="pref_color.tempfail.text"
name="extensions.dkim_verifier.color.tempfail.text"
type="string"/>
<preference id="pref_color.tempfail.background"
name="extensions.dkim_verifier.color.tempfail.background"
type="string"/>

<preference id="pref_color.nosig.text"
name="extensions.dkim_verifier.color.nosig.text"
type="string"/>
Expand All @@ -61,8 +62,21 @@
<preference id="pref_display.favicon.show"
name="extensions.dkim_verifier.display.favicon.show"
type="bool"/>

<preference id="pref_display.advancedInfo.show"
name="extensions.dkim_verifier.advancedInfo.show"
type="bool"/>
<preference id="pref_display.advancedInfo.allSignatures"
name="extensions.dkim_verifier.advancedInfo.allSignatures"
type="bool"/>
<preference id="pref_display.advancedInfo.includeHeaders"
name="extensions.dkim_verifier.advancedInfo.includeHeaders"
type="bool"/>
<preference id="pref_display.advancedInfo.includeDNSSEC"
name="extensions.dkim_verifier.advancedInfo.includeDNSSEC"
type="bool"/>
</preferences>

<groupbox>
<caption label="&color.label;"/>
<checkbox preference="pref_colorFrom" label="&colorFrom.label;"/>
Expand Down Expand Up @@ -179,9 +193,22 @@
<spacer/>
</hbox>
</groupbox>

<groupbox>
<checkbox preference="pref_display.advancedInfo.show"
label="&display.advancedInfo.show.label;"
oncommand="toggleDetailsOptionsEnabled();"
id="display.advancedInfo.show" />
<vbox class="indent">
<checkbox preference="pref_display.advancedInfo.allSignatures"
label="&display.advancedInfo.allSignatures.label;"
id="display.advancedInfo.allSignatures" />
<checkbox preference="pref_display.advancedInfo.includeHeaders"
label="&display.advancedInfo.includeHeaders.label;"
id="display.advancedInfo.includeHeaders" />
</vbox>
</groupbox>
<checkbox preference="pref_display.favicon.show"
label="&display.favicon.show.label;"/>
label="&display.favicon.show.label;"/>
</prefpane>

</overlay>
15 changes: 14 additions & 1 deletion chrome/locale/de/dkim.properties
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,17 @@ DKIM_SIGWARNING_FROM_NOT_IN_AUID = Absender passt nicht zur Benutzeridentität
# DKIM_SIGWARNING - POLICY
DKIM_SIGWARNING_UNSIGNED_HEADER = Kopfzeile '%S' ist nicht signiert

DKIM_SIGERROR_SUBJECT_MODIFIED = Der Betreff wurde verändert: '%S'
DKIM_SIGERROR_SUBJECT_MODIFIED = Der Betreff wurde verändert: '%S'
SUCCESS_FROM_ARH = Gültig (Signiert durch %S, geprüft durch %S)

# DKIM Result Details
DKIM_RESULT_DETAILS_SIG_COUNT = Anzahl der Signaturen: %S
DKIM_RESULT_DETAILS_SIGNED_BY_FOR = Signiert durch %S für %S
DKIM_RESULT_DETAILS_VERIFIED_BY = Signatur wurde geprüft durch %S
DKIM_RESULT_DETAILS_NO_TIME = Kein Signaturzeitpunkt in der Signatur enthalten
DKIM_RESULT_DETAILS_TIME_EXPIRY = Sigiert um %S, läuft ab um %S
DKIM_RESULT_DETAILS_TIME_NO_EXPIRY = Signiert um %S, läuft nie ab
DKIM_RESULT_DETAILS_ALGORITHM = Algorithmus: %S / %S
DKIM_RESULT_DETAILS_ALGORITHM_WITH_LENGTH = Algorithmus: %S (%S Bit) / %S
DKIM_RESULT_DETAILS_HEADERS = Signierte Kopfzeilen: %S
DKIM_RESULT_DETAILS_WARNINGS = Warnungen:\n- %S
6 changes: 5 additions & 1 deletion chrome/locale/de/options.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@
<!ENTITY policy.unsigned_header.mode.value.1.label "Empfohlen">
<!ENTITY policy.unsigned_header.mode.value.2.label "Streng">

<!ENTITY error.sanitizeSubject.label "Versuche Ergänzungen im Betreff zu korrigieren">
<!ENTITY error.sanitizeSubject.label "Versuche Ergänzungen im Betreff zu korrigieren">

<!ENTITY display.advancedInfo.show.label "Erweiterte Signatur-Informationen in Tooltips anzeigen">
<!ENTITY display.advancedInfo.allSignatures.label "Alle Signaturen anzeigen">
<!ENTITY display.advancedInfo.includeHeaders.label "Information über signierte Kopfzeilen anzeigen">
15 changes: 14 additions & 1 deletion chrome/locale/en-US/dkim.properties
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,17 @@ DKIM_SIGWARNING_FROM_NOT_IN_AUID = From does not match the user identifier
# DKIM_SIGWARNING - POLICY
DKIM_SIGWARNING_UNSIGNED_HEADER = Header '%S' is not signed

DKIM_SIGERROR_SUBJECT_MODIFIED = Subject was modified: '%S'
DKIM_SIGERROR_SUBJECT_MODIFIED = Subject was modified: '%S'
SUCCESS_FROM_ARH = Valid (Signed by %S, verified by %S)

# DKIM Result Details
DKIM_RESULT_DETAILS_SIG_COUNT = Signature count: %S
DKIM_RESULT_DETAILS_SIGNED_BY_FOR = Signed by %S for %S
DKIM_RESULT_DETAILS_VERIFIED_BY = Signature was verified by %S
DKIM_RESULT_DETAILS_NO_TIME = No signing time included in signature
DKIM_RESULT_DETAILS_TIME_EXPIRY = Signed at %S, expires at %S
DKIM_RESULT_DETAILS_TIME_NO_EXPIRY = Signed at %S, expires never
DKIM_RESULT_DETAILS_ALGORITHM = Algorithm: %S / %S
DKIM_RESULT_DETAILS_ALGORITHM_WITH_LENGTH = Algorithm: %S (%S bit) / %S
DKIM_RESULT_DETAILS_HEADERS = Signed headers: %S
DKIM_RESULT_DETAILS_WARNINGS = Warnings:\n- %S
6 changes: 5 additions & 1 deletion chrome/locale/en-US/options.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@
<!ENTITY policy.unsigned_header.mode.value.1.label "Recommended">
<!ENTITY policy.unsigned_header.mode.value.2.label "Strict">

<!ENTITY error.sanitizeSubject.label "Try to remove amendments in the subject">
<!ENTITY error.sanitizeSubject.label "Try to remove amendments in the subject">

<!ENTITY display.advancedInfo.show.label "Show extended signature information in tooltips">
<!ENTITY display.advancedInfo.allSignatures.label "Show all signatures">
<!ENTITY display.advancedInfo.includeHeaders.label "Show signed headers">
15 changes: 14 additions & 1 deletion chrome/locale/fr/dkim.properties
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,17 @@ DKIM_SIGWARNING_FROM_NOT_IN_AUID = L'expéditeur ne correspond pas avec l'identi
# DKIM_SIGWARNING - POLICY
DKIM_SIGWARNING_UNSIGNED_HEADER = Header '%S' is not signed

DKIM_SIGERROR_SUBJECT_MODIFIED = Subject was modified: '%S'
DKIM_SIGERROR_SUBJECT_MODIFIED = Subject was modified: '%S'
SUCCESS_FROM_ARH = Valid (Signed by %S, verified by %S)

# DKIM Result Details
DKIM_RESULT_DETAILS_SIG_COUNT = Signature count: %S
DKIM_RESULT_DETAILS_SIGNED_BY_FOR = Signed by %S for %S
DKIM_RESULT_DETAILS_VERIFIED_BY = Signature was verified by %S
DKIM_RESULT_DETAILS_NO_TIME = No signing time included in signature
DKIM_RESULT_DETAILS_TIME_EXPIRY = Signed at %S, expires at %S
DKIM_RESULT_DETAILS_TIME_NO_EXPIRY = Signed at %S, expires never
DKIM_RESULT_DETAILS_ALGORITHM = Algorithm: %S / %S
DKIM_RESULT_DETAILS_ALGORITHM_WITH_LENGTH = Algorithm: %S (%S bit) / %S
DKIM_RESULT_DETAILS_HEADERS = Signed headers: %S
DKIM_RESULT_DETAILS_WARNINGS = Warnings:\n- %S
6 changes: 5 additions & 1 deletion chrome/locale/fr/options.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@
<!ENTITY policy.unsigned_header.mode.value.1.label "Recommended">
<!ENTITY policy.unsigned_header.mode.value.2.label "Strict">

<!ENTITY error.sanitizeSubject.label "Try to remove amendments in the subject">
<!ENTITY error.sanitizeSubject.label "Try to remove amendments in the subject">

<!ENTITY display.advancedInfo.show.label "Show extended signature information in tooltips">
<!ENTITY display.advancedInfo.allSignatures.label "Show all signatures">
<!ENTITY display.advancedInfo.includeHeaders.label "Show signed headers">
15 changes: 14 additions & 1 deletion chrome/locale/hu/dkim.properties
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,17 @@ DKIM_SIGWARNING_FROM_NOT_IN_AUID = A feladó nem egyezik a felhasználói azonos
# DKIM_SIGWARNING - POLICY
DKIM_SIGWARNING_UNSIGNED_HEADER = Header '%S' is not signed

DKIM_SIGERROR_SUBJECT_MODIFIED = Subject was modified: '%S'
DKIM_SIGERROR_SUBJECT_MODIFIED = Subject was modified: '%S'
SUCCESS_FROM_ARH = Valid (Signed by %S, verified by %S)

# DKIM Result Details
DKIM_RESULT_DETAILS_SIG_COUNT = Signature count: %S
DKIM_RESULT_DETAILS_SIGNED_BY_FOR = Signed by %S for %S
DKIM_RESULT_DETAILS_VERIFIED_BY = Signature was verified by %S
DKIM_RESULT_DETAILS_NO_TIME = No signing time included in signature
DKIM_RESULT_DETAILS_TIME_EXPIRY = Signed at %S, expires at %S
DKIM_RESULT_DETAILS_TIME_NO_EXPIRY = Signed at %S, expires never
DKIM_RESULT_DETAILS_ALGORITHM = Algorithm: %S / %S
DKIM_RESULT_DETAILS_ALGORITHM_WITH_LENGTH = Algorithm: %S (%S bit) / %S
DKIM_RESULT_DETAILS_HEADERS = Signed headers: %S
DKIM_RESULT_DETAILS_WARNINGS = Warnings:\n- %S
6 changes: 5 additions & 1 deletion chrome/locale/hu/options.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@
<!ENTITY policy.unsigned_header.mode.value.1.label "Recommended">
<!ENTITY policy.unsigned_header.mode.value.2.label "Strict">

<!ENTITY error.sanitizeSubject.label "Try to remove amendments in the subject">
<!ENTITY error.sanitizeSubject.label "Try to remove amendments in the subject">

<!ENTITY display.advancedInfo.show.label "Show extended signature information in tooltips">
<!ENTITY display.advancedInfo.allSignatures.label "Show all signatures">
<!ENTITY display.advancedInfo.includeHeaders.label "Show signed headers">
15 changes: 14 additions & 1 deletion chrome/locale/it/dkim.properties
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,17 @@ DKIM_SIGWARNING_FROM_NOT_IN_AUID = Il mittente non corrisponde all’identificat
# DKIM_SIGWARNING - POLICY
DKIM_SIGWARNING_UNSIGNED_HEADER = Header '%S' is not signed

DKIM_SIGERROR_SUBJECT_MODIFIED = Subject was modified: '%S'
DKIM_SIGERROR_SUBJECT_MODIFIED = Subject was modified: '%S'
SUCCESS_FROM_ARH = Valid (Signed by %S, verified by %S)

# DKIM Result Details
DKIM_RESULT_DETAILS_SIG_COUNT = Signature count: %S
DKIM_RESULT_DETAILS_SIGNED_BY_FOR = Signed by %S for %S
DKIM_RESULT_DETAILS_VERIFIED_BY = Signature was verified by %S
DKIM_RESULT_DETAILS_NO_TIME = No signing time included in signature
DKIM_RESULT_DETAILS_TIME_EXPIRY = Signed at %S, expires at %S
DKIM_RESULT_DETAILS_TIME_NO_EXPIRY = Signed at %S, expires never
DKIM_RESULT_DETAILS_ALGORITHM = Algorithm: %S / %S
DKIM_RESULT_DETAILS_ALGORITHM_WITH_LENGTH = Algorithm: %S (%S bit) / %S
DKIM_RESULT_DETAILS_HEADERS = Signed headers: %S
DKIM_RESULT_DETAILS_WARNINGS = Warnings:\n- %S
6 changes: 5 additions & 1 deletion chrome/locale/it/options.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@
<!ENTITY policy.unsigned_header.mode.value.1.label "Recommended">
<!ENTITY policy.unsigned_header.mode.value.2.label "Strict">

<!ENTITY error.sanitizeSubject.label "Try to remove amendments in the subject">
<!ENTITY error.sanitizeSubject.label "Try to remove amendments in the subject">

<!ENTITY display.advancedInfo.show.label "Show extended signature information in tooltips">
<!ENTITY display.advancedInfo.allSignatures.label "Show all signatures">
<!ENTITY display.advancedInfo.includeHeaders.label "Show signed headers">
15 changes: 14 additions & 1 deletion chrome/locale/ja-JP/dkim.properties
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,17 @@ DKIM_SIGWARNING_FROM_NOT_IN_AUID = 差出人がユーザ識別子とマッチし
# DKIM_SIGWARNING - POLICY
DKIM_SIGWARNING_UNSIGNED_HEADER = Header '%S' is not signed

DKIM_SIGERROR_SUBJECT_MODIFIED = Subject was modified: '%S'
DKIM_SIGERROR_SUBJECT_MODIFIED = Subject was modified: '%S'
SUCCESS_FROM_ARH = Valid (Signed by %S, verified by %S)

# DKIM Result Details
DKIM_RESULT_DETAILS_SIG_COUNT = Signature count: %S
DKIM_RESULT_DETAILS_SIGNED_BY_FOR = Signed by %S for %S
DKIM_RESULT_DETAILS_VERIFIED_BY = Signature was verified by %S
DKIM_RESULT_DETAILS_NO_TIME = No signing time included in signature
DKIM_RESULT_DETAILS_TIME_EXPIRY = Signed at %S, expires at %S
DKIM_RESULT_DETAILS_TIME_NO_EXPIRY = Signed at %S, expires never
DKIM_RESULT_DETAILS_ALGORITHM = Algorithm: %S / %S
DKIM_RESULT_DETAILS_ALGORITHM_WITH_LENGTH = Algorithm: %S (%S bit) / %S
DKIM_RESULT_DETAILS_HEADERS = Signed headers: %S
DKIM_RESULT_DETAILS_WARNINGS = Warnings:\n- %S
6 changes: 5 additions & 1 deletion chrome/locale/ja-JP/options.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@
<!ENTITY policy.unsigned_header.mode.value.1.label "Recommended">
<!ENTITY policy.unsigned_header.mode.value.2.label "Strict">

<!ENTITY error.sanitizeSubject.label "Try to remove amendments in the subject">
<!ENTITY error.sanitizeSubject.label "Try to remove amendments in the subject">

<!ENTITY display.advancedInfo.show.label "Show extended signature information in tooltips">
<!ENTITY display.advancedInfo.allSignatures.label "Show all signatures">
<!ENTITY display.advancedInfo.includeHeaders.label "Show signed headers">
Loading

0 comments on commit f66afba

Please sign in to comment.