From ef338f7693fe5339d833679aed1c7e7e399b67f2 Mon Sep 17 00:00:00 2001 From: NateN1222 Date: Mon, 26 Mar 2018 12:05:50 -0500 Subject: Fixed failed license recognition bug for script declarations with magnet links --- main_background.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'main_background.js') 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+"
"]; } - var temp = full_evaluate(temp); - temp[1] = temp[1] + "
"; - return temp; + var final = full_evaluate(temp); + final[1] = final[1] + "
"; + 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; -- cgit v1.2.3