From 2cdb441baa21ba4a99d7077f6b043708d181525d Mon Sep 17 00:00:00 2001
From: Ruben Rodriguez <ruben@fsf.org>
Date: Oct 03 2018 22:33:59 +0000
Subject: More generalized license matching


---

diff --git a/main_background.js b/main_background.js
index 5c2e8df..18d3caa 100644
--- a/main_background.js
+++ b/main_background.js
@@ -644,15 +644,23 @@ function evaluate(script,name){
 
 
 function validateLicense(matches) {
-	if (!(Array.isArray(matches) && matches.length === 4)){
+	if (!(Array.isArray(matches) && matches.length >= 4)){
 		return [false, "Malformed or unrecognized license tag."];
 	}
 	let [all, tag, link, id] = matches;
-	let license = licenses[id];
+	let license = null;
+	if (licenses[id])
+		license = licenses[id];
+	for (var key in licenses){
+		if (licenses[key]["Magnet link"]==link)
+			license=licenses[key];
+		if (licenses[key]["URL"]==link)
+			license=licenses[key];
+	}
 	if(!license){
 		return [false, `Unrecognized license "${id}"`];
 	}
-	if(license["Magnet link"] != link){
+	if (!(license["Magnet link"] == link || license["URL"] == link)){
 		return [false, `License magnet link does not match for "${id}".`];
 	}
 	return [true, `Recognized license: "${id}".`];

