Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
Handle wildcards in any position
Browse files Browse the repository at this point in the history
  • Loading branch information
pde committed Sep 4, 2014
1 parent 910d70d commit 4a45bad
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/chrome/content/ruleset-tests.js
Expand Up @@ -52,6 +52,8 @@ function addTestTarget(urls, target, ruleset_ids) {
}
}

var left_star = new RegExp("^\\*\\."); // *.example.com

function testRunner() {
Components.utils.import("resource://gre/modules/PopupNotifications.jsm");

Expand All @@ -64,14 +66,20 @@ function testRunner() {
var ruleset_ids;

for(var target in targets_to_ids) {
var t;
ruleset_ids = targets_to_ids[target];
if(target.indexOf("*") == -1) {
addTestTarget(urls, target, ruleset_ids);
} else {
// target is like *.example.wildcard.com, let's see what we can do...
t = target.replace("*.", "www.");
if (!(t in targets_to_ids)) { addTestTarget(urls, t, ruleset_ids); }
// target is like *.example.wildcard.com, or www.example.*
// let's see what we can do...
var t = target.replace(left_star, "www.");
if (t.indexOf("*") != -1) {
HTTPSEverywhere.log(5, "WARNING target with illegal 2nd star");
continue;
}
if (!(t in targets_to_ids)) {
addTestTarget(urls, t, ruleset_ids);
}
}
}

Expand Down

0 comments on commit 4a45bad

Please sign in to comment.