aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Rodriguez <ruben@fsf.org>2019-05-01 13:57:39 -0400
committerRuben Rodriguez <ruben@fsf.org>2019-05-01 13:57:39 -0400
commite0011f5687213d5e389a7c07b0318bb4f5d30bf9 (patch)
tree0d419e930fbb92f4953a04ada6d6f0ce288aa26c
parent774b48ffb5fda4905ef2afb08eb8a09212d57978 (diff)
Allow for detection of @license declarations with no links. Show human readable license names
-rw-r--r--main_background.js28
1 files changed, 17 insertions, 11 deletions
diff --git a/main_background.js b/main_background.js
index 0a1a2e9..c3688f9 100644
--- a/main_background.js
+++ b/main_background.js
@@ -239,7 +239,6 @@ async function addReportEntry(tabId, scriptHashOrUrl, action) {
let report = activityReports[tabId];
if (!report) report = activityReports[tabId] =
await createReport({tabId});
-
let type, actionValue;
for (type of ["accepted", "blocked", "whitelisted", "blacklisted"]) {
if (type in action) {
@@ -618,21 +617,28 @@ function validateLicense(matches) {
}
let [all, tag, link, id] = matches;
let license = null;
- if (licenses[id])
+ // The match contains a link: @license [magnet|http;//....] LicenseID
+ if (licenses[id]) {
license = licenses[id];
- for (let key in licenses){
- if (licenses[key]["Magnet link"] === link)
- license = licenses[key];
- if (licenses[key]["URL"] === link)
- license = licenses[key];
+ for (let key in licenses){
+ if (licenses[key]["Magnet link"] === link)
+ license = licenses[key];
+ if (licenses[key]["URL"] === link)
+ license = licenses[key];
+ }
+ if (!(license["Magnet link"] === link || license["URL"] === link)){
+ return [false, `License magnet link does not match for "${id}".`];
+ }
+ }
+ // The match does not contain a link: @license LicenseID
+ if (licenses[link]) {
+ license = licenses[link];
+ id = link;
}
if(!license){
return [false, `Unrecognized license "${id}"`];
}
- if (!(license["Magnet link"] === link || license["URL"] === link)){
- return [false, `License magnet link does not match for "${id}".`];
- }
- return [true, `Recognized license: "${id}".`];
+ return [true, `Recognized license: "${license['Name']}".`];
}
/**
*