summaryrefslogtreecommitdiff
path: root/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries
diff options
context:
space:
mode:
authorRuben Rodriguez <ruben@gnu.org>2015-11-28 15:24:36 -0600
committerRuben Rodriguez <ruben@gnu.org>2015-11-28 16:27:06 -0600
commite4a3586a14996bbece3b26c9e3b7704ea6af8615 (patch)
tree499bdd16b3a90c30b01e4b47a5882d13b4800f50 /data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries
parent4dbc2fae927bb02ef243c87938e638af9afee8fa (diff)
LibreJS upgraded to 6.0.10
Diffstat (limited to 'data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries')
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/accepted_scripts.js69
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/all_scripts.js110
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/crypto.js61
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/dryrun_scripts.js78
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/free_libraries.js67
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/removed_scripts.js73
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/scripts_cache.js192
7 files changed, 0 insertions, 650 deletions
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/accepted_scripts.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/accepted_scripts.js
deleted file mode 100644
index c732f31..0000000
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/accepted_scripts.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript.
- * *
- * Copyright (C) 2011, 2012, 2013, 2014 Loic J. Duros
- * Copyright (C) 2014, 2015 Nik Nyby
- *
- * This file is part of GNU LibreJS.
- *
- * GNU LibreJS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GNU LibreJS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>.
- */
-
-var allScripts = require('script_entries/all_scripts').allScripts;
-
-var AcceptedScripts = function() {
- this.scripts = {};
- this.truncateJsData = allScripts.truncateJsData;
- this.getScripts = allScripts.getScripts;
- this.isFound = allScripts.isFound;
- this.returnWhenFound = allScripts.returnWhenFound;
- this.getOrInitScripts = allScripts.getOrInitScripts;
- this.setHash = allScripts.setHash;
-};
-
-AcceptedScripts.prototype.clearScripts = function (url) {
- this.scripts[url] = [];
-};
-
-/**
- * addAScript
- * adds a single script to the scripts array.
- * @param {string} url - the url of the page where it is loaded.
- * @param {object} scriptObj - Additional data regarding this script,
- * including: inline: boolean,
- * contents: string,
- * removalReason: string.
- */
-AcceptedScripts.prototype.addAScript = function (url, scriptObj) {
- var exists;
-
- if (this.scripts[url] === undefined) {
- this.clearScripts(url);
- }
-
- // check if content is actually js code.
- if (scriptObj.inline === true) {
- this.setHash(scriptObj);
- this.truncateJsData(scriptObj);
- }
- exists = this.isFound(url, scriptObj);
- if (!exists) {
- this.scripts[url].push(scriptObj);
- return true;
- } else {
- return false;
- }
-};
-
-exports.acceptedScripts = new AcceptedScripts();
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/all_scripts.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/all_scripts.js
deleted file mode 100644
index 2028864..0000000
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/all_scripts.js
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript.
- * *
- * Copyright (C) 2011, 2012, 2013, 2014 Loic J. Duros
- * Copyright (C) 2014, 2015 Nik Nyby
- *
- * This file is part of GNU LibreJS.
- *
- * GNU LibreJS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GNU LibreJS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>.
- */
-
-var crypto = require('script_entries/crypto');
-
-var AllScripts = function() {
- this.scripts = {};
-};
-
-AllScripts.prototype.truncateJsData = function (scriptObj) {
- if (scriptObj.contents === undefined) {
- console.debug('this is an inline script', scriptObj.value);
- console.debug('this is an src', scriptObj.url);
- }
- if (scriptObj.contents.length > 1000) {
- scriptObj.contents = scriptObj.contents.substring(0, 1000);
- scriptObj.contents += '…';
- }
-};
-
-AllScripts.prototype.setHash = function (scriptObj) {
- scriptObj.hash = crypto.sha1Encrypt(scriptObj.contents);
- return scriptObj.hash;
-};
-
-AllScripts.prototype.getScripts = function (url) {
- if (!this.scripts[url]) {
- return false;
- } else {
- return this.scripts[url];
- }
-};
-
-AllScripts.prototype.reverseArray = function (url) {
- this.scripts[url].reverse();
-};
-
-AllScripts.prototype.getOrInitScripts = function (url) {
- if (this.scripts[url] === undefined) {
- this.scripts[url] = [];
- }
- return this.scripts[url];
-};
-
-AllScripts.prototype.returnWhenFound = function(url, data) {
- var pageScripts = this.getOrInitScripts(url),
- i = 0,
- le = pageScripts.length;
-
- // check that entry doesn't exist.
- if (data.inline === false) {
- for (; i < le; i++) {
- if (pageScripts[i].contents === data.url) {
- return pageScripts[i];
- }
- }
- } else if (data.inline === true) {
- for (; i < le; i++) {
- if (pageScripts[i].hash === crypto.sha1Encrypt(data.contents)) {
- return pageScripts[i];
- }
- }
- }
-
- return false;
-};
-
-AllScripts.prototype.isFound = function(url, data) {
- var pageScripts = this.getOrInitScripts(url),
- i = 0,
- le = pageScripts.length;
-
- // check that entry doesn't exist.
- if (data.inline === false) {
- for (; i < le; i++) {
- if (pageScripts[i].url === data.url) {
- return true;
- }
- }
- } else if (data.inline === true) {
- for (; i < le; i++) {
- if (pageScripts[i].hash === crypto.sha1Encrypt(data.contents)) {
- return true;
- }
- }
- }
-
- return false;
-};
-
-exports.allScripts = new AllScripts();
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/crypto.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/crypto.js
deleted file mode 100644
index d8d9c0a..0000000
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/crypto.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript.
- * *
- * Copyright (C) 2011, 2012, 2013, 2014 Loic J. Duros
- * Copyright (C) 2014, 2015 Nik Nyby
- *
- * This file is part of GNU LibreJS.
- *
- * GNU LibreJS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GNU LibreJS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>.
- */
-
-var {Cc, Ci, Cu, Cm, Cr} = require("chrome");
-
-var CryptoString = function() {
- this.cryptoHash = Cc["@mozilla.org/security/hash;1"]
- .createInstance(Ci.nsICryptoHash);
- this.converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
- createInstance(Ci.nsIScriptableUnicodeConverter);
- this.hashAlgorithm = null;
-};
-
-CryptoString.prototype.init = function(hashAlgorithm, charset) {
- this.converter.charset = charset;
- this.hashAlgorithm = hashAlgorithm;
- this.cryptoHash.init(this.cryptoHash[this.hashAlgorithm]);
-};
-
-CryptoString.prototype.encryptString = function(str) {
- var result = {};
- var data = this.converter.convertToByteArray(str, result);
- this.cryptoHash.update(data, data.length);
- var hash = this.cryptoHash.finish(false);
- return [this.toHexString(hash.charCodeAt(i)) for (i in hash)].join("");
-};
-
-CryptoString.prototype.toHexString = function(charCode) {
- return ("0" + charCode.toString(16)).slice(-2);
-};
-
-var cryptoString = new CryptoString();
-
-exports.sha1Encrypt = function(str) {
- cryptoString.init('SHA1', 'UTF-8');
- return cryptoString.encryptString(str);
-};
-
-exports.sha256Encrypt = function(str) {
- cryptoString.init('SHA256', 'UTF-8');
- return cryptoString.encryptString(str);
-};
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/dryrun_scripts.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/dryrun_scripts.js
deleted file mode 100644
index 87ec482..0000000
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/dryrun_scripts.js
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript.
- * *
- * Copyright (C) 2011, 2012, 2013, 2014 Loic J. Duros
- * Copyright (C) 2014, 2015 Nik Nyby
- *
- * This file is part of GNU LibreJS.
- *
- * GNU LibreJS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GNU LibreJS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>.
- */
-
-var allScripts = require('script_entries/all_scripts').allScripts;
-const urlHandler = require('url_handler/url_handler');
-
-exports.dryRunScripts = {
- scripts: {},
-
- truncateJsData: allScripts.truncateJsData,
-
- getScripts: allScripts.getScripts,
-
- isFound: allScripts.isFound,
-
- returnWhenFound: allScripts.returnWhenFound,
-
- getOrInitScripts: allScripts.getOrInitScripts,
-
- reverseArray: allScripts.reverseArray,
-
- setHash: allScripts.setHash,
-
- clearScripts: function (url) {
- this.scripts[url] = [];
- },
-
- /**
- * addAScript
- * adds a single script to the scripts array.
- * @param {string} url - the url of the page where it is loaded.
- * @param {object} scriptObj - Additional data regarding this script,
- * including: inline: boolean,
- * contents: string,
- * removalReason: string.
- */
- addAScript: function (url, scriptObj, absoluteUrl) {
- var exists;
-
- if (this.scripts[url] === undefined) {
- this.clearScripts(url);
- }
- if (scriptObj.inline === true) {
- this.setHash(scriptObj);
- this.truncateJsData(scriptObj);
- } else if (absoluteUrl !== undefined &&
- scriptObj.inline === false) {
- scriptObj.contents = urlHandler.resolve(absoluteUrl, scriptObj.contents);
- }
- exists = this.isFound(url, scriptObj);
-
- if (!exists) {
- this.scripts[url].push(scriptObj);
- return true;
- } else {
- return false;
- }
- }
-};
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/free_libraries.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/free_libraries.js
deleted file mode 100644
index 8821d04..0000000
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/free_libraries.js
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript.
- * *
- * Copyright (C) 2011, 2012, 2013, 2014 Loic J. Duros
- * Copyright (C) 2014, 2015 Nik Nyby
- *
- * This file is part of GNU LibreJS.
- *
- * GNU LibreJS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GNU LibreJS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// THIS MODULE IS DEPRECATED IN FAVOR OF THE NEW WHITELISTING MODULE (LibreJS 6.0)
-
-var relationChecker = require("js_checker/relation_checker").relationChecker;
-var checkTypes = require("js_checker/constant_types").checkTypes;
-var scriptsCached = require("script_entries/scripts_cache").scriptsCached;
-
-
-// find the json database path.
-var dbContents = require("sdk/self").data.load("script_libraries/script-libraries.json");
-
-const AUTHOR_REASON = "This script has been tagged as free software by LibreJS authors.";
-
-var freeLibraries = JSON.parse(dbContents); /* a database of the free libraries recognized by default */
-
-/*
- * List of free libraries and their SHA256 hash.
- * This is used to recognize the most common free libraries.
- */
-
-var init = function () {
-
- // relationChecker, which roughly checks if variables are window
- // variables or not, is useless in this case. Use the same
- // object for all entries.
- var rc = relationChecker();
- var library, hash;
- var freeObj = { "type": 4, "reason": AUTHOR_REASON};
- console.debug("Building init");
- for (hash in freeLibraries) {
- library = freeLibraries[hash];
-
- // assign empty relationChecker object.
- library.relationChecker = rc;
-
- // make them free and nontrivial.
- library.result = freeObj;
-
- scriptsCached.addObjectEntry(hash, library);
- }
-};
-
-//init();
-
-exports.init = init;
-exports.AUTHOR_REASON = AUTHOR_REASON;
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/removed_scripts.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/removed_scripts.js
deleted file mode 100644
index b7544e9..0000000
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/removed_scripts.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript.
- * *
- * Copyright (C) 2011, 2012, 2013, 2014 Loic J. Duros
- * Copyright (C) 2014, 2015 Nik Nyby
- *
- * This file is part of GNU LibreJS.
- *
- * GNU LibreJS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GNU LibreJS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>.
- */
-
-var allScripts = require('script_entries/all_scripts').allScripts;
-const urlHandler = require('url_handler/url_handler');
-
-var RemovedScripts = function() {
- this.scripts = {};
- this.truncateJsData = allScripts.truncateJsData;
- this.getScripts = allScripts.getScripts;
- this.isFound = allScripts.isFound;
- this.returnWhenFound = allScripts.returnWhenFound;
- this.getOrInitScripts = allScripts.getOrInitScripts;
- this.reverseArray = allScripts.reverseArray;
- this.setHash = allScripts.setHash;
-};
-
-RemovedScripts.prototype.clearScripts = function (url) {
- this.scripts[url] = [];
-};
-
-/**
- * addAScript
- * adds a single script to the scripts array.
- * @param {string} url - the url of the page where it is loaded.
- * @param {object} scriptObj - Additional data regarding this script,
- * including: inline: boolean,
- * contents: string,
- * removalReason: string.
- */
-RemovedScripts.prototype.addAScript = function (url, scriptObj, absoluteUrl) {
- var exists;
-
- if (this.scripts[url] === undefined) {
- this.clearScripts(url);
- }
- if (scriptObj.inline === true) {
- this.setHash(scriptObj);
- this.truncateJsData(scriptObj);
- } else if (absoluteUrl !== undefined &&
- scriptObj.inline === false) {
- scriptObj.contents = urlHandler.resolve(absoluteUrl, scriptObj.contents);
- }
- exists = this.isFound(url, scriptObj);
-
- if (!exists) {
- this.scripts[url].push(scriptObj);
- return true;
- } else {
- return false;
- }
-};
-
-exports.removedScripts = new RemovedScripts();
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/scripts_cache.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/scripts_cache.js
deleted file mode 100644
index 47ab069..0000000
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/script_entries/scripts_cache.js
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript.
- * *
- * Copyright (C) 2011, 2012, 2013, 2014 Loic J. Duros
- * Copyright (C) 2014, 2015 Nik Nyby
- *
- * This file is part of GNU LibreJS.
- *
- * GNU LibreJS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GNU LibreJS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>.
- */
-var relationCheckerObj = require("js_checker/relation_checker")
- .relationChecker;
-
-// import free_libraries to populate the cache hash map.
-var free_libraries = require("script_entries/free_libraries");
-
-var crypto = require('script_entries/crypto');
-const checkTypes = require("js_checker/constant_types").checkTypes;
-
-// cachedResults contains objects with result/relationChecker for
-// scripts entries indexed by SHA1sum
-var cachedResults = {};
-
-/**
- * ScriptsCached keeps a cache of whitelisted scripts in the browser
- * session.
- */
-var ScriptsCached = function() {
-};
-
-ScriptsCached.prototype.getHash = function(scriptText) {
- require('ui/notification').createNotification(scriptText.substring(0,100));
-
- return crypto.sha1Encrypt(scriptText);
-};
-
-/**
- * resetCache
- * Resets the full cache and re-initialize
- * the free libraries list.
- */
-ScriptsCached.prototype.resetCache = function () {
- cachedResults = {};
- free_libraries.init();
-};
-
-/**
- *
- * addEntry
- *
- * Adds a script entry to the cache by providing the results
- * and the actual script text.
- *
- */
-ScriptsCached.prototype.addEntry = function(
- scriptText, result, relationChecker, allowTrivial, url) {
- console.debug("result addEntry is", JSON.stringify(result));
- cachedResults[this.getHash(scriptText)] = {
- 'result': result,
- 'relationChecker': relationCheckerObj(),
- 'allowTrivial': allowTrivial,
- 'url': url
- };
-};
-
-/**
- *
- * addEntry
- *
- * Adds a script entry to the cache by providing the results
- * using the script's hash.
- *
- */
-ScriptsCached.prototype.addEntryByHash = function(
- hash, result, relationChecker, allowTrivial, url) {
- cachedResults[hash] = {
- 'result': result,
- 'relationChecker': relationCheckerObj(),
- 'allowTrivial': allowTrivial,
- 'url': url || ''
- };
-};
-
-/**
- * removeEntryByHash
- *
- * Remove an entry from the cache using hash key.
- */
-ScriptsCached.prototype.removeEntryByHash = function(hash) {
- delete cachedResults[hash];
-};
-
-/**
- * addEntryIfNotCached
- *
- * Checks first if entry is cached before attempting to cache result.
- */
-ScriptsCached.prototype.addEntryIfNotCached = function(
- scriptText, result, relationChecker, allowTrivial, url) {
- // save a bit of computing by getting hash once.
- var hash = this.getHash(scriptText);
- console.debug('hash is then', hash);
- if (!this.isCached(scriptText, hash)) {
- cachedResults[hash] = {
- 'result': result,
- 'relationChecker': relationCheckerObj(),
- 'allowTrivial': allowTrivial,
- 'url': url || ''
- };
- }
- return hash;
-};
-
-/**
- *
- * addObjectEntry
- *
- * Adds a script entry by providing an object.
- * Used to provide free library hashes from free_libraries.js
- *
- */
-ScriptsCached.prototype.addObjectEntry = function(hash, script) {
- cachedResults[hash] = script;
-};
-
-ScriptsCached.prototype.isCached = function(scriptText, hash) {
- var scriptHash;
- console.debug("Is CACHED start?");
- try {
- if (typeof hash === 'string') {
- scriptHash = hash;
- } else {
- scriptHash = this.getHash(scriptText);
- }
- if (typeof scriptHash === 'string') {
- let cachedResult = cachedResults[scriptHash];
- if (cachedResult) {
- // exact copy of file has already been cached.
- console.debug('scriptHash is', cachedResult);
- if (cachedResult.relationChecker == "[rl]") {
- cachedResult.relationChecker = {}; //relationCheckerObj();
- }
- console.debug("Is Cached ENd TRUE");
- return cachedResult;
- }
- }
- return false;
- } catch (e) {
- console.debug("an error", scriptHash, e, e.linenumber, e.filename);
- }
-};
-
-/**
- * Writes allowed scripts to the cache.
- * nonfree/nontrivial scripts are not added to the cache.
- */
-ScriptsCached.prototype.getCacheForWriting = function() {
- var formattedResults = {};
- for (let item in cachedResults) {
- let type = cachedResults[item].result.type;
- if (type != checkTypes.NONTRIVIAL &&
- type != checkTypes.TRIVIAL_DEFINES_FUNCTION
- ) {
- formattedResults[item] = cachedResults[item];
- }
- }
- return formattedResults;
-};
-
-/**
- * Import data from database into cachedResults.
- * Calling this function replaces the current cache if it exists.
- */
-ScriptsCached.prototype.bulkImportCache = function(data) {
- cachedResults = data;
- console.debug("Imported data. Number of keys ISSS ",
- Object.keys(cachedResults).length);
- console.debug("It looks like ", JSON.stringify(cachedResults));
-};
-
-exports.scriptsCached = new ScriptsCached();