Skip to content

Commit

Permalink
Reverted to tabs (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
dodmi committed Jan 7, 2024
1 parent 71df36b commit fdb12bf
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 209 deletions.
72 changes: 36 additions & 36 deletions modules/ARHParser.jsm.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* ARHParser.jsm.js
*
*
* Parser for the Authentication-Results header as specified in RFC 7601.
*
* Version: 1.2.1 (13 January 2019)
*
*
* Copyright (c) 2014-2019 Philippe Lieser
*
*
* This software is licensed under the terms of the MIT License.
*
*
* The above copyright and license notice shall be
* included in all copies or substantial portions of the Software.
*/
Expand Down Expand Up @@ -56,26 +56,26 @@ const log = Logging.getLogger("ARHParser");
* @property {String} method
* @property {Number} [method_version]
* @property {String} result
* none|pass|fail|softfail|policy|neutral|temperror|permerror
* none|pass|fail|softfail|policy|neutral|temperror|permerror
* @property {String} [reason]
* @property {Object} propertys
* @property {Object} propertys.smtp
* @property {Object} propertys.header
* @property {Object} propertys.body
* @property {Object} propertys.policy
* @property {Object} [propertys._Keyword_]
* ARHResinfo can also include other propertys besides the aboves.
* ARHResinfo can also include other propertys besides the aboves.
*/

let ARHParser = {
get version() { return module_version; },

/**
* Parses an Authentication-Results header.
*
* @param {String} authresHeader Authentication-Results header
* @return {ARHHeader} Parsed Authentication-Results header
* @throws {DKIM_Error}
* Parses an Authentication-Results header.
*
* @param {String} authresHeader Authentication-Results header
* @return {ARHHeader} Parsed Authentication-Results header
* @throws {DKIM_Error}
*/
parse: function _ARHParser_parse(authresHeader) {
// remove header name
Expand Down Expand Up @@ -122,19 +122,19 @@ let ARHParser = {
};

/**
* Parses the next resinfo in str. The parsed part of str is removed from str.
*
* @param {RefString} str
* @return {ARHResinfo|null} Parsed resinfo
* @throws {DKIM_Error|Error}
* Parses the next resinfo in str. The parsed part of str is removed from str.
*
* @param {RefString} str
* @return {ARHResinfo|null} Parsed resinfo
* @throws {DKIM_Error|Error}
*/
function parseResinfo(str) {
log.trace("parse str: " + str.toSource());

let reg_match;
/** @type {ARHResinfo} */
let res = {};

// get methodspec
const method_version_p = `${rfcParser.get("CFWS_op")}/${rfcParser.get("CFWS_op")}([0-9]+)`;
const method_p = `(${rfcParser.get("Keyword")})(?:${method_version_p})?`;
Expand Down Expand Up @@ -196,7 +196,7 @@ function parseResinfo(str) {
}
if (!reg_match[2]) {
throw new DKIM_Error("Error matching the ARH property sub-name.");
}
}
let property = res.propertys[reg_match[1]];
if (!property) {
property = {};
Expand Down Expand Up @@ -280,15 +280,15 @@ class RefString {
}

/**
* Matches a pattern to the beginning of str.
* Adds CFWS_op to the beginning of pattern.
* pattern must be followed by string end, ";" or CFWS_p.
* Removes the found match from str.
*
* @param {RefString} str
* @param {String} pattern
* @return {String[]} An Array, containing the matches
* @throws {DKIM_Error} if match no match found
* Matches a pattern to the beginning of str.
* Adds CFWS_op to the beginning of pattern.
* pattern must be followed by string end, ";" or CFWS_p.
* Removes the found match from str.
*
* @param {RefString} str
* @param {String} pattern
* @return {String[]} An Array, containing the matches
* @throws {DKIM_Error} if match no match found
*/
function match(str, pattern) {
const reg_match = match_o(str, pattern);
Expand All @@ -300,15 +300,15 @@ function match(str, pattern) {
}

/**
* Tries to matches a pattern to the beginning of str.
* Adds CFWS_op to the beginning of pattern.
* pattern must be followed by string end, ";" or CFWS_p.
* If match is found, removes it from str.
*
* @param {RefString} str
* @param {String} pattern
* @return {String[]|Null} Null if no match for the pattern is found, else
* an Array, containing the matches
* Tries to matches a pattern to the beginning of str.
* Adds CFWS_op to the beginning of pattern.
* pattern must be followed by string end, ";" or CFWS_p.
* If match is found, removes it from str.
*
* @param {RefString} str
* @param {String} pattern
* @return {String[]|Null} Null if no match for the pattern is found, else
* an Array, containing the matches
*/
function match_o(str, pattern) {
const regexp = new RegExp(`^${rfcParser.get("CFWS_op")}(?:${pattern})(?:(?:${rfcParser.get("CFWS_op")}\r\n$)|(?=;)|(?=${rfcParser.get("CFWS")}))`);
Expand Down
18 changes: 9 additions & 9 deletions modules/bimi.jsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* The above copyright and license notice shall be
* included in all copies or substantial portions of the Software.
*/

// options for ESLint
/* global Components */
/* global Logging, rfcParser */
Expand All @@ -34,8 +34,8 @@ Cu.import("resource://dkim_verifier/logging.jsm.js");
Cu.import("resource://dkim_verifier/ARHParser.jsm.js");
Cu.import("resource://dkim_verifier/rfcParser.jsm.js");

let BIMI = (function() {

let BIMI = (function() {
const log = Logging.getLogger("BIMI");

let that = {
Expand All @@ -50,9 +50,9 @@ let BIMI = (function() {
// Assuming:
// 1. We only get ARHs that can be trusted (i.e. from the receiving MTA).
// 2. If the receiving MTA does not supports BIMI,
// we will not see an ARH with a BIMI result (because of 1)
// we will not see an ARH with a BIMI result (because of 1)
// 3. If the receiving MTA supports BIMI,
// it will make sure we only see his BIMI-Indicator headers (as required by the RFC).
// it will make sure we only see his BIMI-Indicator headers (as required by the RFC).
//
// Given the above, it should be safe to trust the BIMI indicator from the BIMI-Indicator header
// if we have a passing BIMI result there the MTA claims to have checked the Authority Evidence.
Expand All @@ -64,7 +64,7 @@ let BIMI = (function() {
if (!hasAuthorityPassBIMI) {
return null;
}

const bimiIndicators = headers.get("bimi-indicator") || [];
if (bimiIndicators.length > 1) {
log.warn("Message contains more than one BIMI-Indicator header");
Expand All @@ -75,14 +75,14 @@ let BIMI = (function() {
log.warn("Message contains an ARH with passing BIMI but does not have a BIMI-Indicator header");
return null;
}

// TODO: If in the future we support ARC we might want to check the policy.indicator-hash

// Remove header name and new line at end
bimiIndicator = bimiIndicator.slice("bimi-indicator:".length, -"\r\n".length);
// Remove all whitespace
bimiIndicator = bimiIndicator.replace(new RegExp(`${rfcParser.get("FWS")}`, "g"), "");

return bimiIndicator;
}
};
Expand Down
Loading

0 comments on commit fdb12bf

Please sign in to comment.