aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNateN1222 <nathannichols454@gmail.com>2018-03-26 12:05:50 -0500
committerNateN1222 <nathannichols454@gmail.com>2018-03-26 12:05:50 -0500
commitef338f7693fe5339d833679aed1c7e7e399b67f2 (patch)
tree2c6ee5fde98353a55825bc918af162cf3ffa535e
parentc46613c7054dbc674a1189caa6c7262dcdeef986 (diff)
Fixed failed license recognition bug for script declarations with magnet links
-rw-r--r--legacy_license_check.js16
-rw-r--r--main_background.js20
2 files changed, 21 insertions, 15 deletions
diff --git a/legacy_license_check.js b/legacy_license_check.js
index dc3458a..00d341e 100644
--- a/legacy_license_check.js
+++ b/legacy_license_check.js
@@ -49,11 +49,10 @@ var license_regexes = [];
var init = function(){
console.log("initializing regexes");
-
for (var item in data.licenses) {
license_regexes.push(stripLicenseToRegexp(data.licenses[item]));
}
- console.log(license_regexes);
+ //console.log(license_regexes);
}
module.exports.init = init;
@@ -67,8 +66,8 @@ var search_table = function(stripped_comment){
var stripped = match_utils.removeNonalpha(stripped_comment);
//stripped = stripped.replaceTokens(stripped_comment);
- console.log("Looking up license");
- console.log(stripped);
+ //console.log("Looking up license");
+ //console.log(stripped);
for (license in data.licenses) {
frag = data.licenses[license].licenseFragments;
@@ -90,11 +89,11 @@ var search_table = function(stripped_comment){
* returns true for "free" and false for anything else
*/
var check = function(license_text){
- console.log("checking...");
- console.log(license_text);
+ //console.log("checking...");
+ //console.log(license_text);
if(license_text === undefined || license_text === null || license_text == ""){
- console.log("Was not an inline script");
+ //console.log("Was not an inline script");
return false;
}
// remove whitespace
@@ -106,9 +105,6 @@ var check = function(license_text){
return false;
}
var declaration = matches[0];
-
- console.log("Got to this point");
- console.log(declaration);
return search_table(declaration);
diff --git a/main_background.js b/main_background.js
index 30ed411..b159ff1 100644
--- a/main_background.js
+++ b/main_background.js
@@ -663,6 +663,8 @@ function full_evaluate(script){
try{
var toke = tokens.getToken();
}catch(e){
+ console.log(script);
+ console.log(e);
console.warn("couldn't get first token (probably invalid code)");
console.warn("Continuing evaluation");
}
@@ -815,9 +817,9 @@ function evaluate(script,name){
return [flag,reason+"<br>"];
}
- var temp = full_evaluate(temp);
- temp[1] = temp[1] + "<br>";
- return temp;
+ var final = full_evaluate(temp);
+ final[1] = final[1] + "<br>";
+ return final;
}
@@ -859,7 +861,7 @@ function license_read(script_src, name){
var parts_accepted = false;
while(true){ // TODO: refactor me
// TODO: support multiline comments
- var matches = /\/\s*?(@license)\s([\S]+)\s([\S]+$)/gm.exec(unedited_src);
+ var matches = /\/\/\s*?(@license)\s([\S]+)\s([\S]+$)/gm.exec(unedited_src);
if(matches == null){
nontrivial_status = evaluate(unedited_src,name);
if(nontrivial_status[0] == true){
@@ -880,7 +882,15 @@ function license_read(script_src, name){
else return [true,edited_src,reason_text];
}
- var before = unedited_src.substr(0,matches["index"]);
+ // sponge
+ console.log("undedited_src:");
+ console.log(unedited_src);
+ console.log(matches);
+ console.log("chopping at " + matches["index"] + ".");
+ var before = unedited_src.substring(0,matches["index"]);
+ // sponge
+ console.log("before:");
+ console.log(before);
nontrivial_status = evaluate(before,name);
if(nontrivial_status[0] == true){
parts_accepted = true;