Skip to content

Commit d3beec3

Browse files
committed
Remove 6 years old legacy code handling migrations from NoScript 5.x "Classic".
1 parent ec04a2e commit d3beec3

File tree

5 files changed

+10
-577
lines changed

5 files changed

+10
-577
lines changed

src/bg/Settings.js

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ var Settings = {
2222

2323
async import(data) {
2424

25-
// figure out whether it's just a whitelist, a legacy backup or a "Quantum" export
25+
// figure out whether it's just a trusted/untrusted list, a serialized policy or a full settings export
2626
try {
2727
let json = JSON.parse(data);
28-
if (json.whitelist) {
29-
return await this.importLegacy(json);
30-
}
3128
if (json.trusted) {
3229
return await this.importPolicy(json);
3330
}
@@ -40,26 +37,16 @@ var Settings = {
4037
}
4138
},
4239

43-
async importLegacy(json) {
44-
await include("/legacy/Legacy.js");
45-
if (await Legacy.import(json)) {
46-
try {
47-
ns.policy = Legacy.migratePolicy();
48-
await ns.savePolicy();
49-
await Legacy.persist();
50-
return true;
51-
} catch (e) {
52-
error(e, "Importing legacy settings");
53-
Legacy.migrated = Legacy.undo;
54-
}
55-
}
56-
return false;
57-
},
58-
5940
async importLists(data) {
60-
await include("/legacy/Legacy.js");
41+
const extractLists = lists =>
42+
lists.map(listString => listString.split(/\s+/))
43+
.map(sites => sites.filter(s => !(
44+
s.includes(":") &&
45+
sites.includes(s.replace(/.*:\/*(?=\w)/g, ""))
46+
)));
47+
6148
try {
62-
let [trusted, untrusted] = Legacy.extractLists(data.split("[UNTRUSTED]"));
49+
let [trusted, untrusted] = extractLists(data.split("[UNTRUSTED]"));
6350
let policy = ns.policy;
6451
for (let site of trusted) {
6552
policy.set(site, policy.TRUSTED);

src/bg/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@
7676
await ns.savePolicy();
7777
}
7878
} else {
79-
await include("/legacy/Legacy.js");
80-
ns.policy = await Legacy.createOrMigratePolicy();
79+
ns.policy = new Policy(Settings.createDefaultDryPolicy());
8180
await ns.savePolicy();
8281
}
8382
}

src/legacy/Legacy.js

Lines changed: 0 additions & 167 deletions
This file was deleted.

0 commit comments

Comments
 (0)