Skip to content

Commit

Permalink
Allow multiple '*' globs in the From pattern (#471)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: lieser <lieser@users.noreply.github.com>
  • Loading branch information
namelessmasses and lieser authored Jan 1, 2025
1 parent 9294dc5 commit 45a864e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"gecko": {
"id": "dkim_verifier@pl",
"strict_min_version": "91.0",
"strict_max_version": "121.*"
"strict_max_version": "128.*"
}
},
"permissions": [
Expand Down
2 changes: 1 addition & 1 deletion modules/dkim/signRules.mjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function glob(str, pattern) {
// escape all special regex charters besides *
let regexpPattern = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
// replace * with correct regex
regexpPattern = regexpPattern.replace("*", ".*");
regexpPattern = regexpPattern.replace(/\*/g, ".*");

const regexp = new RegExp(`^${regexpPattern}$`, "i");
return regexp.test(str);
Expand Down
8 changes: 8 additions & 0 deletions test/unittest/signRulesSpec.mjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ describe("Sign rules [unittest]", function () {

res = await SignRules.check(dkimNone, "bar@a.foo.comX");
expect(res.result).is.equal("none");

await SignRules.addRule("bar.com", null, "*@mail.*.bar.com", "bar.com", SignRules.TYPE.ALL);
res = await SignRules.check(dkimNone, "@mail.a.bar.com");
expect(res.result).is.equal("PERMFAIL");
res = await SignRules.check(dkimNone, "test@mail.foo.bar.com");
expect(res.result).is.equal("PERMFAIL");
res = await SignRules.check(dkimNone, "test@foo.bar.com");
expect(res.result).is.equal("none");
});
it("Add user exception", async function () {
let res = await SignRules.check(dkimNone, "bar@paypal.com");
Expand Down

0 comments on commit 45a864e

Please sign in to comment.