From 5da28b0f8771834ae208d61431d632875e9f8e7d Mon Sep 17 00:00:00 2001 From: Ruben Rodriguez Date: Thu, 8 Sep 2022 20:18:54 -0400 Subject: Updated extensions: * Upgraded Privacy Redirect to 1.1.49 and configured to use the 10 most reliable invidious instances * Removed ViewTube * Added torproxy@icecat.gnu based on 'Proxy toggle' extension * Added jShelter 0.11.1 * Upgraded LibreJS to 7.21.0 * Upgraded HTTPS Everywhere to 2021.7.13 * Upgraded SubmitMe to 1.9 --- .../jid1-KtlZuoiikVfFew@jetpack/bundle.js | 6981 +++++++++----------- 1 file changed, 2996 insertions(+), 3985 deletions(-) (limited to 'data/extensions/jid1-KtlZuoiikVfFew@jetpack/bundle.js') diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/bundle.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/bundle.js index 155cf87..c6ce36e 100644 --- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/bundle.js +++ b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/bundle.js @@ -24,15 +24,15 @@ Singleton to handle external licenses, e.g. WebLabels */ -"use strict"; +'use strict'; let licensesByLabel = new Map(); let licensesByUrl = new Map(); { - let {licenses} = require("../license_definitions"); + let { licenses } = require('../license_definitions'); let mapByLabel = (label, license) => licensesByLabel.set(label.toUpperCase(), license); for (let [id, l] of Object.entries(licenses)) { - let {identifier, canonicalUrl, licenseName} = l; + let { identifier, canonicalUrl, licenseName } = l; if (identifier) { mapByLabel(identifier, l); } else { @@ -60,25 +60,25 @@ var ExternalLicenses = { }, async check(script) { - let {url, tabId, frameId, documentUrl} = script; + let { url, tabId, frameId, documentUrl } = script; let tabCache = cachedHrefs.get(tabId); let frameCache = tabCache && tabCache.get(frameId); let cache = frameCache && frameCache.get(documentUrl); let scriptInfo = await browser.tabs.sendMessage(tabId, { - action: "checkLicensedScript", + action: 'checkLicensedScript', url, cache, - }, {frameId}); + }, { frameId }); if (!(scriptInfo && scriptInfo.licenseLinks.length)) { return null; } scriptInfo.licenses = new Set(); scriptInfo.toString = function() { - let licenseIds = [...this.licenses].map(l => l.identifier).sort().join(", "); + let licenseIds = [...this.licenses].map(l => l.identifier).sort().join(', '); return licenseIds - ? `Free license${this.licenses.size > 1 ? "s" : ""} (${licenseIds})` - : "Unknown license(s)"; + ? `Free license${this.licenses.size > 1 ? 's' : ''} (${licenseIds})` + : 'Unknown license(s)'; } let match = (map, key) => { if (map.has(key)) { @@ -88,7 +88,7 @@ var ExternalLicenses = { return false; }; - for (let {label, url} of scriptInfo.licenseLinks) { + for (let { label, url } of scriptInfo.licenseLinks) { match(licensesByLabel, label = label.trim().toUpperCase()) || match(licensesByUrl, url) || match(licensesByLabel, label.replace(/^GNU-|-(?:OR-LATER|ONLY)$/, '')); @@ -104,31 +104,32 @@ var ExternalLicenses = { * modify the rendered HTML but rather feed the content script on demand. * Returns true if the document has been actually modified, false otherwise. */ - optimizeDocument(document, cachePointer) { + optimizeDocument(doc, cachePointer) { let cache = {}; - let {tabId, frameId, documentUrl} = cachePointer; + let { tabId, frameId, documentUrl } = cachePointer; let frameCache = cachedHrefs.get(tabId); if (!frameCache) { cachedHrefs.set(tabId, frameCache = new Map()); } frameCache.set(frameId, new Map([[documentUrl, cache]])); - let link = document.querySelector(`link[rel="jslicense"], link[data-jslicense="1"], a[rel="jslicense"], a[data-jslicense="1"]`); + let link = doc.querySelector('link[rel="jslicense"], link[data-jslicense="1"], a[rel="jslicense"], a[data-jslicense="1"]'); if (link) { - let href = link.getAttribute("href"); - cache.webLabels = {href}; - let move = () => !!document.head.insertBefore(link, document.head.firstChild); - if (link.parentNode === document.head) { - for (let node; node = link.previousElementSibling;) { - if (node.tagName.toUpperCase() === "SCRIPT") { + let href = link.getAttribute('href'); + cache.webLabels = { href }; + let move = () => !!doc.head.insertBefore(link, doc.head.firstChild); + if (link.parentNode === doc.head) { + let node = link.previousElementSibling; + for (; node; node = node.previousElementSibling) { + if (node.tagName.toUpperCase() === 'SCRIPT') { return move(); } } } else { // the reference is only in the body - if (link.tagName.toUpperCase() === "A") { - let newLink = document.createElement("link"); - newLink.rel = "jslicense"; - newLink.setAttribute("href", href); + if (link.tagName.toUpperCase() === 'A') { + let newLink = doc.createElement('link'); + newLink.rel = 'jslicense'; + newLink.setAttribute('href', href); link = newLink; } return move(); @@ -168,11 +169,11 @@ module.exports = { ExternalLicenses }; A class to manage whitelist/blacklist operations */ -let {ListStore} = require("../common/Storage"); +let { ListStore } = require('../common/Storage'); class ListManager { constructor(whitelist, blacklist, builtInHashes) { - this.lists = {whitelist, blacklist}; + this.lists = { whitelist, blacklist }; this.builtInHashes = new Set(builtInHashes); } @@ -193,14 +194,14 @@ class ListManager { with a trailing (hash). Returns "blacklisted", "whitelisted" or defValue */ - getStatus(key, defValue = "unknown") { - let {blacklist, whitelist} = this.lists; + getStatus(key, defValue = 'unknown') { + let { blacklist, whitelist } = this.lists; let inline = ListStore.inlineItem(key); if (inline) { return blacklist.contains(inline) - ? "blacklisted" - : whitelist.contains(inline) ? "whitelisted" - : defValue; + ? 'blacklisted' + : whitelist.contains(inline) ? 'whitelisted' + : defValue; } let match = key.match(/\(([^)]+)\)(?=[^()]*$)/); @@ -208,40 +209,40 @@ class ListManager { let url = ListStore.urlItem(key); let site = ListStore.siteItem(key); return (blacklist.contains(url) || ListManager.siteMatch(site, blacklist) - ? "blacklisted" + ? 'blacklisted' : whitelist.contains(url) || ListManager.siteMatch(site, whitelist) - ? "whitelisted" : defValue + ? 'whitelisted' : defValue ); } - let [hashItem, srcHash] = match; // (hash), hash - return blacklist.contains(hashItem) ? "blacklisted" - : this.builtInHashes.has(srcHash) || whitelist.contains(hashItem) - ? "whitelisted" - : defValue; - } + let [hashItem, srcHash] = match; // (hash), hash + return blacklist.contains(hashItem) ? 'blacklisted' + : this.builtInHashes.has(srcHash) || whitelist.contains(hashItem) + ? 'whitelisted' + : defValue; + } - /* - Matches by whole site ("http://some.domain.com/*") supporting also - wildcarded subdomains ("https://*.domain.com/*"). - */ - static siteMatch(url, list) { - let site = ListStore.siteItem(url); + /* + Matches by whole site ("http://some.domain.com/*") supporting also + wildcarded subdomains ("https://*.domain.com/*"). + */ + static siteMatch(url, list) { + let site = ListStore.siteItem(url); + if (list.contains(site)) { + return site; + } + site = site.replace(/^([\w-]+:\/\/)?(\w)/, '$1*.$2'); + for (; ;) { if (list.contains(site)) { return site; } - site = site.replace(/^([\w-]+:\/\/)?(\w)/, "$1*.$2"); - for (;;) { - if (list.contains(site)) { - return site; - } - let oldKey = site; - site = site.replace(/(?:\*\.)*\w+(?=\.)/, "*"); - if (site === oldKey) { - return null; - } + let oldKey = site; + site = site.replace(/(?:\*\.)*\w+(?=\.)/, '*'); + if (site === oldKey) { + return null; } } + } } module.exports = { ListManager }; @@ -275,32 +276,32 @@ module.exports = { ListManager }; */ const BOM = [0xEF, 0xBB, 0xBF]; -const DECODER_PARAMS = {stream: true}; +const DECODER_PARAMS = { stream: true }; class ResponseMetaData { constructor(request) { - let {responseHeaders} = request; + let { responseHeaders } = request; this.headers = {}; for (let h of responseHeaders) { if (/^\s*Content-(Type|Disposition)\s*$/i.test(h.name)) { - let propertyName = h.name.split("-")[1].trim(); + let propertyName = h.name.split('-')[1].trim(); propertyName = `content${propertyName.charAt(0).toUpperCase()}${propertyName.substring(1).toLowerCase()}`; this[propertyName] = h.value; this.headers[propertyName] = h; } } - this.computedCharset = ""; + this.computedCharset = ''; } get charset() { - let charset = ""; + let charset = ''; if (this.contentType) { let m = this.contentType.match(/;\s*charset\s*=\s*(\S+)/); if (m) { charset = m[1]; } } - Object.defineProperty(this, "charset", { value: charset, writable: false, configurable: true }); + Object.defineProperty(this, 'charset', { value: charset, writable: false, configurable: true }); return this.computedCharset = charset; } @@ -318,12 +319,12 @@ class ResponseMetaData { // let's try figuring out the charset from tags let parser = new DOMParser(); - let doc = parser.parseFromString(text, "text/html"); + let doc = parser.parseFromString(text, 'text/html'); let meta = doc.querySelectorAll('meta[charset], meta[http-equiv="content-type"], meta[content*="charset"]'); for (let m of meta) { - charset = m.getAttribute("charset"); + charset = m.getAttribute('charset'); if (!charset) { - let match = m.getAttribute("content").match(/;\s*charset\s*=\s*([\w-]+)/i) + let match = m.getAttribute('content').match(/;\s*charset\s*=\s*([\w-]+)/i) if (match) charset = match[1]; } if (charset) { @@ -338,7 +339,7 @@ class ResponseMetaData { return text; } - createDecoder(charset = this.charset, def = "latin1") { + createDecoder(charset = this.charset, def = 'latin1') { if (charset) { try { return new TextDecoder(charset); @@ -348,7 +349,7 @@ class ResponseMetaData { } return def ? new TextDecoder(def) : null; } -}; +} ResponseMetaData.UTF8BOM = new Uint8Array(BOM); module.exports = { ResponseMetaData }; @@ -380,23 +381,23 @@ module.exports = { ResponseMetaData }; only the "interesting" HTML and script requests and leaving the other alone */ -let {ResponseMetaData} = require("./ResponseMetaData"); +let { ResponseMetaData } = require('./ResponseMetaData'); let listeners = new WeakMap(); let webRequestEvent = browser.webRequest.onHeadersReceived; class ResponseProcessor { - static install(handler, types = ["main_frame", "sub_frame", "script"]) { + static install(handler, types = ['main_frame', 'sub_frame', 'script']) { if (listeners.has(handler)) return false; let listener = - async request => await new ResponseTextFilter(request).process(handler); + async request => await new ResponseTextFilter(request).process(handler); listeners.set(handler, listener); webRequestEvent.addListener( - listener, - {urls: [""], types}, - ["blocking", "responseHeaders"] - ); + listener, + { urls: [''], types }, + ['blocking', 'responseHeaders'] + ); return true; } @@ -410,34 +411,34 @@ class ResponseProcessor { Object.assign(ResponseProcessor, { // control flow values to be returned by handler.pre() callbacks - ACCEPT: {}, - REJECT: {cancel: true}, - CONTINUE: null + ACCEPT: {}, + REJECT: { cancel: true }, + CONTINUE: null }); class ResponseTextFilter { constructor(request) { this.request = request; - let {type, statusCode} = request; + let { type, statusCode } = request; let md = this.metaData = new ResponseMetaData(request); this.canProcess = // we want to process html documents and scripts only (statusCode < 300 || statusCode >= 400) && // skip redirections !md.disposition && // skip forced downloads - (type === "script" || /\bhtml\b/i.test(md.contentType)); + (type === 'script' || /\bhtml\b/i.test(md.contentType)); } async process(handler) { if (!this.canProcess) return ResponseProcessor.ACCEPT; - let {metaData, request} = this; - let response = {request, metaData}; // we keep it around allowing callbacks to store state - if (typeof handler.pre === "function") { + let { metaData, request } = this; + let response = { request, metaData }; // we keep it around allowing callbacks to store state + if (typeof handler.pre === 'function') { let res = await handler.pre(response); if (res) return res; if (handler.post) handler = handler.post; - if (typeof handler !== "function") return ResponseProcessor.ACCEPT; + if (typeof handler !== 'function') return ResponseProcessor.ACCEPT; } - let {requestId, responseHeaders} = request; + let { requestId } = request; let filter = browser.webRequest.filterResponseData(requestId); let buffer = []; @@ -445,9 +446,9 @@ class ResponseTextFilter { buffer.push(event.data); }; - filter.onstop = async event => { + filter.onstop = async unused => { // concatenate chunks - let size = buffer.reduce((sum, chunk, n) => sum + chunk.byteLength, 0) + let size = buffer.reduce((sum, chunk) => sum + chunk.byteLength, 0) let allBytes = new Uint8Array(size); let pos = 0; for (let chunk of buffer) { @@ -456,13 +457,13 @@ class ResponseTextFilter { } buffer = null; // allow garbage collection if (allBytes.indexOf(0) !== -1) { - console.debug("Warning: zeroes in bytestream, probable cached encoding mismatch.", request); - if (request.type === "script") { - console.debug("It's a script, trying to refetch it."); - response.text = await (await fetch(request.url, {cache: "reload", credentials: "include"})).text(); + console.debug('Warning: zeroes in bytestream, probable cached encoding mismatch.', request); + if (request.type === 'script') { + console.debug('It\'s a script, trying to refetch it.'); + response.text = await (await fetch(request.url, { cache: 'reload', credentials: 'include' })).text(); } else { - console.debug("It's a %s, trying to decode it as UTF-16.", request.type); - response.text = new TextDecoder("utf-16be").decode(allBytes, {stream: true}); + console.debug('It\'s a %s, trying to decode it as UTF-16.', request.type); + response.text = new TextDecoder('utf-16be').decode(allBytes, { stream: true }); } } else { response.text = metaData.decode(allBytes); @@ -470,10 +471,10 @@ class ResponseTextFilter { let editedText = null; try { editedText = await handler(response); - } catch(e) { + } catch (e) { console.error(e); } - if (editedText !== null) { + if (editedText !== null && editedText.indexOf('/* LibreJS: script accepted') !== 0) { // we changed the content, let's re-encode let encoded = new TextEncoder().encode(editedText); // pre-pending the UTF-8 BOM will force the charset per HTML 5 specs @@ -517,7 +518,7 @@ module.exports = { ResponseProcessor }; A tiny wrapper around extensions storage API, supporting CSV serialization for retro-compatibility */ -"use strict"; +'use strict'; var Storage = { ARRAY: { @@ -528,7 +529,7 @@ var Storage = { return array ? new Set(array) : new Set(); }, async save(key, list) { - return await browser.storage.local.set({[key]: [...list]}); + return await browser.storage.local.set({ [key]: [...list] }); }, }, @@ -539,7 +540,7 @@ var Storage = { }, async save(key, list) { - return await browser.storage.local.set({[key]: [...list].join(",")}); + return await browser.storage.local.set({ [key]: [...list].join(',') }); } } }; @@ -562,20 +563,20 @@ class ListStore { static inlineItem(url) { // here we simplify and hash inline script references - return url.startsWith("inline:") ? url - : url.startsWith("view-source:") - && url.replace(/^view-source:[\w-+]+:\/+([^/]+).*#line\d+/,"inline://$1#") - .replace(/\n[^]*/, s => s.replace(/\s+/g, ' ').substring(0, 16) + "…" + hash(s.trim())); + return url.startsWith('inline:') ? url + : url.startsWith('view-source:') + && url.replace(/^view-source:[\w-+]+:\/+([^/]+).*#line\d+/, 'inline://$1#') + .replace(/\n[^]*/, s => s.replace(/\s+/g, ' ').substring(0, 16) + '…' + hash(s.trim())); } static hashItem(hash) { - return hash.startsWith("(") ? hash : `(${hash})`; + return hash.startsWith('(') ? hash : `(${hash})`; } static urlItem(url) { - let queryPos = url.indexOf("?"); + let queryPos = url.indexOf('?'); return queryPos === -1 ? url : url.substring(0, queryPos); } static siteItem(url) { - if (url.endsWith("/*")) return url; + if (url.endsWith('/*')) return url; try { return `${new URL(url).origin}/*`; } catch (e) { @@ -627,18 +628,18 @@ class ListStore { } } -function hash(source){ - var shaObj = new jssha("SHA-256","TEXT") - shaObj.update(source); - return shaObj.getHash("HEX"); +function hash(source) { + var shaObj = new jssha('SHA-256', 'TEXT') + shaObj.update(source); + return shaObj.getHash('HEX'); } -if (typeof module === "object") { +if (typeof module === 'object') { module.exports = { ListStore, Storage, hash }; var jssha = require('jssha'); } -},{"jssha":15}],6:[function(require,module,exports){ +},{"jssha":13}],6:[function(require,module,exports){ /** * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript. * @@ -660,9 +661,9 @@ if (typeof module === "object") { * along with GNU LibreJS. If not, see . */ -"use strict"; +'use strict'; var Test = (() => { - const RUNNER_URL = browser.extension.getURL("/test/SpecRunner.html"); + const RUNNER_URL = browser.extension.getURL('/test/SpecRunner.html'); return { /* returns RUNNER_URL if it's a test-enabled build or an about:debugging @@ -681,23 +682,23 @@ var Test = (() => { async getTab(activate = false) { let url = await this.getURL(); - let tab = url ? (await browser.tabs.query({url}))[0] || - (await browser.tabs.create({url})) + let tab = url ? (await browser.tabs.query({ url }))[0] || + (await browser.tabs.create({ url })) : null; if (tab && activate) { - await browser.tabs.update(tab.id, {active: true}); + await browser.tabs.update(tab.id, { active: true }); } return tab; } }; })(); -if (typeof module === "object") { +if (typeof module === 'object') { module.exports = Test; } },{}],7:[function(require,module,exports){ -module.exports=module.exports = { - fname_data : { +module.exports={ + "fname_data": { "WebGLShader": true, "WebGLShaderPrecisionFormat": true, "WebGLQuery": true, @@ -1527,7 +1528,7 @@ module.exports=module.exports = { "NodeList": true, "StopIteration": true } -}; +} },{}],8:[function(require,module,exports){ module.exports = { @@ -1556,10 +1557,10 @@ module.exports = { * along with GNU LibreJS. If not, see . */ -var data = require("./license_definitions.js"); -var match_utils = require("./pattern_utils.js").patternUtils; +const { licenses } = require('./license_definitions.js'); +const { patternUtils } = require('./pattern_utils.js'); -var licStartLicEndRe = /@licstartThefollowingistheentirelicensenoticefortheJavaScriptcodeinthis(?:page|file)(.*)?@licendTheaboveistheentirelicensenoticefortheJavaScriptcodeinthis(?:page|file)/mi; +const licStartLicEndRe = /@licstartThefollowingistheentirelicensenoticefortheJavaScriptcodeinthis(?:page|file)(.*)?@licendTheaboveistheentirelicensenoticefortheJavaScriptcodeinthis(?:page|file)/mi; /** @@ -1570,26 +1571,19 @@ var licStartLicEndRe = /@licstartThefollowingistheentirelicensenoticefortheJavaS * hardcoded in license_definitions.js * */ -var stripLicenseToRegexp = function (license) { - var max = license.licenseFragments.length; - var item; - for (var i = 0; i < max; i++) { - item = license.licenseFragments[i]; - item.regex = match_utils.removeNonalpha(item.text); - item.regex = new RegExp( - match_utils.replaceTokens(item.regex), ''); - } - return license; +const stripLicenseToRegexp = function(license) { + for (const frag of license.licenseFragments) { + frag.regex = patternUtils.removeNonalpha(frag.text); + frag.regex = new RegExp( + patternUtils.replaceTokens(frag.regex), ''); + } }; -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); +const init = function() { + console.log('initializing regexes'); + for (const key in licenses) { + stripLicenseToRegexp(licenses[key]); + } } module.exports.init = init; @@ -1599,25 +1593,19 @@ module.exports.init = init; * Takes in the declaration that has been preprocessed and * tests it against regexes in our table. */ -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); - - for (license in data.licenses) { - frag = data.licenses[license].licenseFragments; - max_i = data.licenses[license].licenseFragments.length; - for (i = 0; i < max_i; i++) { - if (frag[i].regex.test(stripped)) { - //console.log(data.licenses[license].licenseName); - return data.licenses[license].licenseName; - } - } - } - console.log("No global license found."); - return false; +const searchTable = function(strippedComment) { + const stripped = patternUtils.removeNonalpha(strippedComment); + // looking up license + for (const key in licenses) { + const license = licenses[key]; + for (const frag of license.licenseFragments) { + if (frag.regex.test(stripped)) { + return license.licenseName; + } + } + } + console.log('No global license found.'); + return false; } @@ -1625,31 +1613,25 @@ var search_table = function(stripped_comment){ * Takes the "first comment available on the page" * returns true for "free" and false for anything else */ -var check = function(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"); - return false; - } - // remove whitespace - var stripped = match_utils.removeWhitespace(license_text); - // Search for @licstart/@licend - // This assumes that there isn't anything before the comment - var matches = stripped.match(licStartLicEndRe); - if(matches == null){ - return false; - } - var declaration = matches[0]; - - return search_table(declaration); - +const check = function(licenseText) { + if (licenseText === undefined || licenseText === null || licenseText == '') { + // not an inline script + return false; + } + // remove whitespace + const stripped = patternUtils.removeWhitespace(licenseText); + // Search for @licstart/@licend + // This assumes that there isn't anything before the comment + const matches = stripped.match(licStartLicEndRe); + if (matches == null) { + return false; + } + return searchTable(matches[0]); }; module.exports.check = check; -},{"./license_definitions.js":10,"./pattern_utils.js":16}],10:[function(require,module,exports){ +},{"./license_definitions.js":10,"./pattern_utils.js":14}],10:[function(require,module,exports){ /** * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript. * * @@ -1672,12 +1654,12 @@ module.exports.check = check; * along with GNU LibreJS. If not, see . */ exports.types = { - SHORT: 'short', - LAZY: 'lazy', - FULL: 'full' + SHORT: 'short', + LAZY: 'lazy', + FULL: 'full' }; -var type = exports.types; +const type = exports.types; /** * List of all the licenses. @@ -1688,501 +1670,383 @@ var type = exports.types; * https://spdx.org/licenses/ */ exports.licenses = { - 'CC0-1.0': { - licenseName: 'Creative Commons CC0 1.0 Universal', - identifier: 'CC0-1.0', - canonicalUrl: [ - 'http://creativecommons.org/publicdomain/zero/1.0/legalcode', - 'magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt' - ], - licenseFragments: [] - }, + 'AGPL-3.0': { + licenseName: 'GNU AFFERO GENERAL PUBLIC LICENSE version 3', + identifier: 'AGPL-3.0', + canonicalUrl: [ + 'http://www.gnu.org/licenses/agpl-3.0.html', + 'magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt' + ], + + licenseFragments: [{ text: " is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.", type: type.SHORT }] + }, + 'Apache-2.0': { + licenseName: 'Apache License, Version 2.0', + identifier: 'Apache-2.0', + canonicalUrl: [ + 'http://www.apache.org/licenses/LICENSE-2.0', + 'magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt' + ], + licenseFragments: [{ text: "Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0", type: type.SHORT }] + }, - 'GPL-2.0': { - licenseName: 'GNU General Public License (GPL) version 2', - identifier: 'GPL-2.0', - canonicalUrl: [ - 'http://www.gnu.org/licenses/gpl-2.0.html', - 'magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt' - ], - licenseFragments: [{text: " 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 2 of the License, or (at your option) any later version.", type: type.SHORT}, - {text:"Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the \"GPL\"), or the GNU Lesser General Public License Version 2.1 or later (the \"LGPL\"), in which case the provisions of the GPL or the LGPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of either the GPL or the LGPL, and not to allow others to use your version of this file under the terms of the MPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL or the LGPL. If you do not delete the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL.", type: type.SHORT}] - }, + 'Artistic-2.0': { + licenseName: "Artistic License 2.0", + identifier: 'Artistic-2.0', + canonicalUrl: [ + "http://www.perlfoundation.org/artistic_license_2_0", + "magnet:?xt=urn:btih:54fd2283f9dbdf29466d2df1a98bf8f65cafe314&dn=artistic-2.0.txt" + ], + licenseFragments: [] + }, - 'GPL-3.0': { - licenseName: 'GNU General Public License (GPL) version 3', - identifier: 'GPL-3.0', - canonicalUrl: [ - 'http://www.gnu.org/licenses/gpl-3.0.html', - 'magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt' - ], - licenseFragments: [ - {text: " is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License (GNU GPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The code is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. As additional permission under GNU GPL version 3 section 7, you may distribute non-source (e.g., minimized or compacted) forms of that code without the copy of the GNU GPL normally required by section 4, provided you include this license notice and a URL through which recipients can access the Corresponding Source.", type: type.SHORT}, - {text: " 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.", type: type.SHORT}] - }, + 'BSD-2-Clause': { + licenseName: "BSD 2-Clause License", + identifier: 'BSD-2-Clause', + canonicalUrl: [ + 'http://www.freebsd.org/copyright/freebsd-license.html', + 'magnet:?xt=urn:btih:87f119ba0b429ba17a44b4bffcab33165ebdacc0&dn=freebsd.txt' + ], + licenseFragments: [{ text: "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.", type: type.SHORT }] + }, - 'GNU-All-Permissive': { - licenseName: 'GNU All-Permissive License', - licenseFragments: [{text: "Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.", type: type.SHORT}] - }, + 'BSD-3-Clause': { + licenseName: "BSD 3-Clause License", + identifier: 'BSD-3-Clause', + canonicalUrl: [ + 'http://opensource.org/licenses/BSD-3-Clause', + 'magnet:?xt=urn:btih:c80d50af7d3db9be66a4d0a86db0286e4fd33292&dn=bsd-3-clause.txt' + ], + licenseFragments: [{ text: "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.", type: type.SHORT }] + }, - 'Apache-2.0': { - licenseName: 'Apache License, Version 2.0', - identifier: 'Apache-2.0', - canonicalUrl: [ - 'http://www.apache.org/licenses/LICENSE-2.0', - 'magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt' - ], - licenseFragments: [{text: "Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0", type: type.SHORT}] - }, + 'BSL-1.0': { + licenseName: 'Boost Software License 1.0', + identifier: 'BSL-1.0', + canonicalUrl: [ + 'http://www.boost.org/LICENSE_1_0.txt', + 'magnet:?xt=urn:btih:89a97c535628232f2f3888c2b7b8ffd4c078cec0&dn=Boost-1.0.txt' + ], + licenseFragments: [{ text: "Boost Software License Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the \"Software\") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following", type: type.SHORT }] + }, - 'LGPL-2.1': { - licenseName: 'GNU Lesser General Public License, version 2.1', - identifier: 'LGPL-2.1', - canonicalUrl: [ - 'http://www.gnu.org/licenses/lgpl-2.1.html', - 'magnet:?xt=urn:btih:5de60da917303dbfad4f93fb1b985ced5a89eac2&dn=lgpl-2.1.txt' - ], - licenseFragments: [{text: " is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.", type: type.SHORT}] - }, + 'CC-BY-1.0': { + licenseName: 'Creative Commons Attribution 1.0 Generic', + identifier: 'CC-BY-1.0', + canonicalUrl: ['https://creativecommons.org/licenses/by/1.0/'], + licenseFragments: [] + }, - 'LGPL-3.0': { - licenseName: 'GNU Lesser General Public License, version 3', - identifier: 'LGPL-3.0', - canonicalUrl: [ - 'http://www.gnu.org/licenses/lgpl-3.0.html', - 'magnet:?xt=urn:btih:0ef1b8170b3b615170ff270def6427c317705f85&dn=lgpl-3.0.txt' - ], - licenseFragments: [{text: " is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.", type: type.SHORT}] - }, + 'CC-BY-2.0': { + licenseName: 'Creative Commons Attribution 2.0 Generic', + identifier: 'CC-BY-2.0', + canonicalUrl: ['https://creativecommons.org/licenses/by/2.0/'], + licenseFragments: [] + }, - 'AGPL-3.0': { - licenseName: 'GNU AFFERO GENERAL PUBLIC LICENSE version 3', - identifier: 'AGPL-3.0', - canonicalUrl: [ - 'http://www.gnu.org/licenses/agpl-3.0.html', - 'magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt' - ], + 'CC-BY-2.5': { + licenseName: 'Creative Commons Attribution 2.5 Generic', + identifier: 'CC-BY-2.5', + canonicalUrl: ['https://creativecommons.org/licenses/by/2.5/'], + licenseFragments: [] + }, - licenseFragments: [{text: " is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.", type: type.SHORT}] - }, + 'CC-BY-3.0': { + licenseName: 'Creative Commons Attribution 3.0 Unported', + identifier: 'CC-BY-3.0', + canonicalUrl: ['https://creativecommons.org/licenses/by/3.0/'], + licenseFragments: [] + }, - 'BSL-1.0': { - licenseName: 'Boost Software License 1.0', - identifier: 'BSL-1.0', - canonicalUrl: [ - 'http://www.boost.org/LICENSE_1_0.txt', - 'magnet:?xt=urn:btih:89a97c535628232f2f3888c2b7b8ffd4c078cec0&dn=Boost-1.0.txt' - ], - licenseFragments: [{text: "Boost Software License Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the \"Software\") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following", type: type.SHORT}] - }, + 'CC-BY-4.0': { + licenseName: 'Creative Commons Attribution 4.0 International', + identifier: 'CC-BY-4.0', + canonicalUrl: ['https://creativecommons.org/licenses/by/4.0/'], + licenseFragments: [] + }, - 'BSD-3-Clause': { - licenseName: "BSD 3-Clause License", - identifier: 'BSD-3-Clause', - canonicalUrl: [ - 'http://opensource.org/licenses/BSD-3-Clause', - 'magnet:?xt=urn:btih:c80d50af7d3db9be66a4d0a86db0286e4fd33292&dn=bsd-3-clause.txt' - ], - licenseFragments: [{text: "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.", type: type.SHORT}] - }, + 'CC-BY-SA-1.0': { + licenseName: 'Creative Commons Attribution-ShareAlike 1.0 Generic', + identifier: 'CC-BY-SA-1.0', + canonicalUrl: ['https://creativecommons.org/licenses/by-sa/1.0/'], + licenseFragments: [] + }, - 'BSD-2-Clause': { - licenseName: "BSD 2-Clause License", - identifier: 'BSD-2-Clause', - licenseFragments: [{text: "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.", type: type.SHORT}] - }, + 'CC-BY-SA-2.0': { + licenseName: 'Creative Commons Attribution-ShareAlike 2.0 Generic', + identifier: 'CC-BY-SA-2.0', + canonicalUrl: ['https://creativecommons.org/licenses/by-sa/2.0/'], + licenseFragments: [] + }, - 'EPL-1.0': { - licenseName: "Eclipse Public License Version 1.0", - identifier: "EPL-1.0", - canonicalUrl: [ - "http://www.eclipse.org/legal/epl-v10.html", - "magnet:?xt=urn:btih:4c6a2ad0018cd461e9b0fc44e1b340d2c1828b22&dn=epl-1.0.txt" - ], - licenseFragments: [ - { - text: "THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (\"AGREEMENT\"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.", - type: type.SHORT - } - ] - }, + 'CC-BY-SA-2.5': { + licenseName: 'Creative Commons Attribution-ShareAlike 2.5 Generic', + identifier: 'CC-BY-SA-2.5', + canonicalUrl: ['https://creativecommons.org/licenses/by-sa/2.5/'], + licenseFragments: [] + }, - 'MPL-2.0': { - licenseName: 'Mozilla Public License Version 2.0', - identifier: 'MPL-2.0', - canonicalUrl: [ - 'http://www.mozilla.org/MPL/2.0', - 'magnet:?xt=urn:btih:3877d6d54b3accd4bc32f8a48bf32ebc0901502a&dn=mpl-2.0.txt' - ], - licenseFragments: [{text: "This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.", type: type.SHORT }] - }, + 'CC-BY-SA-3.0': { + licenseName: 'Creative Commons Attribution-ShareAlike 3.0 Unported', + identifier: 'CC-BY-SA-3.0', + canonicalUrl: ['https://creativecommons.org/licenses/by-sa/3.0/'], + licenseFragments: [] + }, - 'Expat': { - licenseName: 'Expat License (sometimes called MIT Licensed)', - identifier: 'Expat', - canonicalUrl: [ - 'http://www.jclark.com/xml/copying.txt', - 'magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt' - ], - licenseFragments: [{text: "Copyright Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.", type: type.SHORT}] - }, + 'CC-BY-SA-4.0': { + licenseName: 'Creative Commons Attribution-ShareAlike 4.0 International', + identifier: 'CC-BY-SA-4.0', + canonicalUrl: ['https://creativecommons.org/licenses/by-sa/4.0/'], + licenseFragments: [] + }, - 'UPL': { - licenseName: 'Universal Permissive License', - identifier: 'UPL-1.0', - canonicalUrl: [ - 'magnet:?xt=urn:btih:5305d91886084f776adcf57509a648432709a7c7&dn=x11.txt' - ], - licenseFragments: [{ - text: "The Universal Permissive License (UPL), Version 1.0", - type: type.SHORT - }] - }, + 'CC0-1.0': { + licenseName: 'Creative Commons CC0 1.0 Universal', + identifier: 'CC0-1.0', + canonicalUrl: [ + 'http://creativecommons.org/publicdomain/zero/1.0/legalcode', + 'magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt' + ], + licenseFragments: [] + }, - 'X11': { - licenseName: 'X11 License', - identifier: 'X11', - canonicalUrl: [ - 'magnet:?xt=urn:btih:5305d91886084f776adcf57509a648432709a7c7&dn=x11.txt' - ], - licenseFragments: [{text: "Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.", type: type.SHORT}] - }, + 'CECILL-2.0': { + licenseName: 'CeCILL Free Software License Agreement v2.0', + identifier: 'CECILL-2.0', + canonicalUrl: [ + 'https://www.cecill.info/licences/Licence_CeCILL_V2-en.txt', + 'magnet:?xt=urn:btih:dda0473d240d7febeac8fa265da27286ead0b1ce&dn=cecill-2.0.txt' + ], + licenseFragments: [] + }, - 'XFree86-1.1': { - licenseName: "XFree86 1.1 License", - identifier: 'XFree86-1.1', - canonicalUrl: [ - 'http://www.xfree86.org/3.3.6/COPYRIGHT2.html#3', - 'http://www.xfree86.org/current/LICENSE4.html', - 'magnet:?xt=urn:btih:12f2ec9e8de2a3b0002a33d518d6010cc8ab2ae9&dn=xfree86.txt' - ], - licenseFragments: [{text: "All rights reserved.\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution, and in the same place and form as other copyright, license and disclaimer information.\n3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: \"This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors\", in the same place and form as other third-party acknowledgments. Alternately, this acknowledgment may appear in the software itself, in the same form and location as other such third-party acknowledgments.4. Except as contained in this notice, the name of The XFree86 Project, Inc shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The XFree86 Project, Inc.", type: type.SHORT} - ] - }, + 'CPAL-1.0': { + licenseName: 'Common Public Attribution License Version 1.0 (CPAL)', + identifier: 'CPAL-1.0', + canonicalUrl: [ + 'http://opensource.org/licenses/cpal_1.0', + 'magnet:?xt=urn:btih:84143bc45939fc8fa42921d619a95462c2031c5c&dn=cpal-1.0.txt' + ], + licenseFragments: [ + { + text: 'The contents of this file are subject to the Common Public Attribution License Version 1.0', + type: type.SHORT + }, + { + text: 'The term "External Deployment" means the use, distribution, or communication of the Original Code or Modifications in any way such that the Original Code or Modifications may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Code or Modifications as a distribution under section 3.1 and make Source Code available under Section 3.2.', + type: type.SHORT + } + ] + }, - 'FreeBSD': { - licenseName: "FreeBSD License", - identifier: 'FreeBSD', - canonicalUrl: [ - 'http://www.freebsd.org/copyright/freebsd-license.html', - 'magnet:?xt=urn:btih:87f119ba0b429ba17a44b4bffcab33165ebdacc0&dn=freebsd.txt' - ], - licenseFragments: [{text: "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.", type: type.SHORT}] - }, + 'EPL-1.0': { + licenseName: "Eclipse Public License Version 1.0", + identifier: "EPL-1.0", + canonicalUrl: [ + "http://www.eclipse.org/legal/epl-v10.html", + "magnet:?xt=urn:btih:4c6a2ad0018cd461e9b0fc44e1b340d2c1828b22&dn=epl-1.0.txt" + ], + licenseFragments: [ + { + text: "THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (\"AGREEMENT\"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.", + type: type.SHORT + } + ] + }, - 'ISC': { - licenseName: "The ISC License", - identifier: 'ISC', - canonicalUrl: [ - 'https://www.isc.org/downloads/software-support-policy/isc-license/', - 'magnet:?xt=urn:btih:b8999bbaf509c08d127678643c515b9ab0836bae&dn=ISC.txt' - ], - licenseFragments: [{text: "Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.", type: type.SHORT}, - {text: "Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.", type: type.SHORT}] - }, + 'Expat': { + licenseName: 'Expat License (sometimes called MIT Licensed)', + identifier: 'Expat', + canonicalUrl: [ + 'http://www.jclark.com/xml/copying.txt', + 'magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt' + ], + licenseFragments: [{ text: "Copyright Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.", type: type.SHORT }] + }, - 'jQueryTools': { - licenseName: "jQuery Tools", - licenseFragments: [{ - text: 'NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.', - type: type.SHORT - }] - }, + 'FreeBSD': { + licenseName: "FreeBSD License", + identifier: 'FreeBSD', + canonicalUrl: [ + 'http://www.freebsd.org/copyright/freebsd-license.html', + 'magnet:?xt=urn:btih:87f119ba0b429ba17a44b4bffcab33165ebdacc0&dn=freebsd.txt' + ], + licenseFragments: [{ text: "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.", type: type.SHORT }] + }, - 'Artistic-2.0': { - licenseName: "Artistic License 2.0", - identifier: 'Artistic-2.0', - canonicalUrl: [ - "http://www.perlfoundation.org/artistic_license_2_0", - "magnet:?xt=urn:btih:54fd2283f9dbdf29466d2df1a98bf8f65cafe314&dn=artistic-2.0.txt" - ], - licenseFragments: [] - }, + 'GNU-All-Permissive': { + licenseName: 'GNU All-Permissive License', + identifier: 'GNU-All-Permissive', + canonicalUrl: [], + licenseFragments: [{ text: "Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.", type: type.SHORT }] + }, - 'PublicDomain': { - licenseName: "Public Domain", - canonicalUrl: [ - 'magnet:?xt=urn:btih:e95b018ef3580986a04669f1b5879592219e2a7a&dn=public-domain.txt' - ], - licenseFragments: [] - }, + 'GPL-2.0': { + licenseName: 'GNU General Public License (GPL) version 2', + identifier: 'GPL-2.0', + canonicalUrl: [ + 'http://www.gnu.org/licenses/gpl-2.0.html', + 'magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt' + ], + licenseFragments: [{ text: " 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 2 of the License, or (at your option) any later version.", type: type.SHORT }, + { text: "Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the \"GPL\"), or the GNU Lesser General Public License Version 2.1 or later (the \"LGPL\"), in which case the provisions of the GPL or the LGPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of either the GPL or the LGPL, and not to allow others to use your version of this file under the terms of the MPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL or the LGPL. If you do not delete the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL.", type: type.SHORT }] + }, - 'CPAL-1.0': { - licenseName: 'Common Public Attribution License Version 1.0 (CPAL)', - identifier: 'CPAL-1.0', - canonicalUrl: [ - 'http://opensource.org/licenses/cpal_1.0', - 'magnet:?xt=urn:btih:84143bc45939fc8fa42921d619a95462c2031c5c&dn=cpal-1.0.txt' - ], - licenseFragments: [ - { - text: 'The contents of this file are subject to the Common Public Attribution License Version 1.0', - type: type.SHORT - }, - { - text: 'The term "External Deployment" means the use, distribution, or communication of the Original Code or Modifications in any way such that the Original Code or Modifications may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Code or Modifications as a distribution under section 3.1 and make Source Code available under Section 3.2.', - type: type.SHORT - } - ] - }, - 'WTFPL': { - licenseName: 'Do What The F*ck You Want To Public License (WTFPL)', - identifier: 'WTFPL', - canonicalUrl: [ - 'http://www.wtfpl.net/txt/copying/', - 'magnet:?xt=urn:btih:723febf9f6185544f57f0660a41489c7d6b4931b&dn=wtfpl.txt' - ], - licenseFragments: [ - { - text: 'DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE', - type: type.SHORT - }, - { - text: '0. You just DO WHAT THE FUCK YOU WANT TO.', - type: type.SHORT - } - ] - }, - 'Unlicense': { - licenseName: 'Unlicense', - identifier: 'Unlicense', - canonicalUrl: [ - 'http://unlicense.org/UNLICENSE', - 'magnet:?xt=urn:btih:5ac446d35272cc2e4e85e4325b146d0b7ca8f50c&dn=unlicense.txt' - ], - licenseFragments: [ - { - text: 'This is free and unencumbered software released into the public domain.', - type: type.SHORT - }, - ] - } -}; + 'GPL-3.0': { + licenseName: 'GNU General Public License (GPL) version 3', + identifier: 'GPL-3.0', + canonicalUrl: [ + 'http://www.gnu.org/licenses/gpl-3.0.html', + 'magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt' + ], + licenseFragments: [ + { text: " is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License (GNU GPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The code is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. As additional permission under GNU GPL version 3 section 7, you may distribute non-source (e.g., minimized or compacted) forms of that code without the copy of the GNU GPL normally required by section 4, provided you include this license notice and a URL through which recipients can access the Corresponding Source.", type: type.SHORT }, + { text: " 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.", type: type.SHORT }] + }, -},{}],11:[function(require,module,exports){ -module.exports=module.exports = { - licenses: { - 'Apache-2.0':{ - 'Name': 'Apache 2.0', - 'URL': 'http://www.apache.org/licenses/LICENSE-2.0', - 'Magnet link': 'magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt' - }, - 'Artistic-2.0':{ - 'Name': 'Artistic 2.0', - 'URL': 'http://www.perlfoundation.org/artistic_license_2_0', - 'Magnet link': 'magnet:?xt=urn:btih:54fd2283f9dbdf29466d2df1a98bf8f65cafe314&dn=artistic-2.0.txt' - }, - 'Boost':{ - 'Name': 'Boost', - 'URL': 'http://www.boost.org/LICENSE_1_0.txt', - 'Magnet link': 'magnet:?xt=urn:btih:89a97c535628232f2f3888c2b7b8ffd4c078cec0&dn=Boost-1.0.txt' - }, - 'CPAL-1.0':{ - 'Name': 'CPAL 1.0', - 'URL': 'http://opensource.org/licenses/cpal_1.0', - 'Magnet link': 'magnet:?xt=urn:btih:84143bc45939fc8fa42921d619a95462c2031c5c&dn=cpal-1.0.txt' - }, - 'CC0-1.0':{ - 'Name': 'CC0 1.0', - 'URL': 'http://creativecommons.org/publicdomain/zero/1.0/legalcode', - 'Magnet link': 'magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt' - }, - 'CC-BY-SA-1.0':{ - 'Name': 'CC-BY-SA 1.0', - 'URL': 'https://creativecommons.org/licenses/by-sa/1.0/', - 'Magnet link': '' - }, - 'CC-BY-SA-2.0':{ - 'Name': 'CC-BY-SA 2.0', - 'URL': 'https://creativecommons.org/licenses/by-sa/2.0/', - 'Magnet link': '' - }, - 'CC-BY-SA-2.5':{ - 'Name': 'CC-BY-SA 2.5', - 'URL': 'https://creativecommons.org/licenses/by-sa/2.5/', - 'Magnet link': '' - }, - 'CC-BY-SA-3.0':{ - 'Name': 'CC-BY-SA 3.0', - 'URL': 'https://creativecommons.org/licenses/by-sa/3.0/', - 'Magnet link': '' - }, - 'CC-BY-SA-4.0':{ - 'Name': 'CC-BY-SA 4.0', - 'URL': 'https://creativecommons.org/licenses/by-sa/4.0/', - 'Magnet link': '' - }, - 'CC-BY-1.0':{ - 'Name': 'CC-BY 1.0', - 'URL': 'https://creativecommons.org/licenses/by/1.0/', - 'Magnet link': '' - }, - 'CC-BY-2.0':{ - 'Name': 'CC-BY 2.0', - 'URL': 'https://creativecommons.org/licenses/by/2.0/', - 'Magnet link': '' - }, - 'CC-BY-2.5':{ - 'Name': 'CC-BY 2.5', - 'URL': 'https://creativecommons.org/licenses/by/2.5/', - 'Magnet link': '' - }, - 'CC-BY-3.0':{ - 'Name': 'CC-BY 3.0', - 'URL': 'https://creativecommons.org/licenses/by/3.0/', - 'Magnet link': '' - }, - 'CC-BY-4.0':{ - 'Name': 'CC-BY 4.0', - 'URL': 'https://creativecommons.org/licenses/by/4.0/', - 'Magnet link': '' - }, - 'EPL-1.0':{ - 'Name': 'EPL 1.0', - 'URL': 'http://www.eclipse.org/legal/epl-v10.html', - 'Magnet link': 'magnet:?xt=urn:btih:4c6a2ad0018cd461e9b0fc44e1b340d2c1828b22&dn=epl-1.0.txt' - }, - 'Expat':{ - 'Name': 'Expat', - 'URL': 'http://www.jclark.com/xml/copying.txt', - 'Magnet link': 'magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt' - }, - 'MIT':{ - 'Name': 'Expat', - 'URL': 'http://www.jclark.com/xml/copying.txt', - 'Magnet link': 'magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt' - }, - 'X11':{ - 'Name': 'X11', - 'URL': 'http://www.xfree86.org/3.3.6/COPYRIGHT2.html#3', - 'Magnet link': 'magnet:?xt=urn:btih:5305d91886084f776adcf57509a648432709a7c7&dn=x11.txt' - }, - 'GPL-2.0':{ - 'Name': 'GPL 2.0', - 'URL': 'http://www.gnu.org/licenses/gpl-2.0.html', - 'Magnet link': 'magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt' - }, - 'GPL-3.0':{ - 'Name': 'GPL 3.0', - 'URL': 'http://www.gnu.org/licenses/gpl-3.0.html', - 'Magnet link': 'magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt' - }, - 'LGPL-2.1':{ - 'Name': 'LGPL 2.1', - 'URL': 'http://www.gnu.org/licenses/lgpl-2.1.html', - 'Magnet link': 'magnet:?xt=urn:btih:5de60da917303dbfad4f93fb1b985ced5a89eac2&dn=lgpl-2.1.txt' - }, - 'LGPL-3.0':{ - 'Name': 'LGPL 3.0', - 'URL': 'http://www.gnu.org/licenses/lgpl-3.0.html', - 'Magnet link': 'magnet:?xt=urn:btih:0ef1b8170b3b615170ff270def6427c317705f85&dn=lgpl-3.0.txt' - }, - 'AGPL-3.0':{ - 'Name': 'AGPL 3.0', - 'URL': 'http://www.gnu.org/licenses/agpl-3.0.html', - 'Magnet link': 'magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt' - }, - 'GPL-2.0-only':{ - 'Name': 'GPL 2.0', - 'URL': 'http://www.gnu.org/licenses/gpl-2.0.html', - 'Magnet link': '' - }, - 'GPL-3.0-only':{ - 'Name': 'GPL 3.0', - 'URL': 'http://www.gnu.org/licenses/gpl-3.0.html', - 'Magnet link': '' - }, - 'LGPL-2.1-only':{ - 'Name': 'LGPL 2.1', - 'URL': 'http://www.gnu.org/licenses/lgpl-2.1.html', - 'Magnet link': '' - }, - 'LGPL-3.0-only':{ - 'Name': 'LGPL 3.0', - 'URL': 'http://www.gnu.org/licenses/lgpl-3.0.html', - 'Magnet link': '' - }, - 'AGPL-3.0-only':{ - 'Name': 'AGPL 3.0', - 'URL': 'http://www.gnu.org/licenses/agpl-3.0.html', - 'Magnet link': '' - }, - 'GPL-2.0-or-later':{ - 'Name': 'GPL 2.0 or later', - 'URL': 'http://www.gnu.org/licenses/gpl-2.0.html', - 'Magnet link': 'magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt' - }, - 'GPL-3.0-or-later':{ - 'Name': 'GPL 3.0 or later', - 'URL': 'http://www.gnu.org/licenses/gpl-3.0.html', - 'Magnet link': 'magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt' - }, - 'LGPL-2.1-or-later':{ - 'Name': 'LGPL 2.1 or later', - 'URL': 'http://www.gnu.org/licenses/lgpl-2.1.html', - 'Magnet link': 'magnet:?xt=urn:btih:5de60da917303dbfad4f93fb1b985ced5a89eac2&dn=lgpl-2.1.txt' - }, - 'LGPL-3.0-or-later':{ - 'Name': 'LGPL 3.0 or later', - 'URL': 'http://www.gnu.org/licenses/lgpl-3.0.html', - 'Magnet link': 'magnet:?xt=urn:btih:0ef1b8170b3b615170ff270def6427c317705f85&dn=lgpl-3.0.txt' - }, - 'AGPL-3.0-or-later':{ - 'Name': 'AGPL 3.0 or later', - 'URL': 'http://www.gnu.org/licenses/agpl-3.0.html', - 'Magnet link': 'magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt' - }, - 'ISC':{ - 'Name': 'ISC', - 'URL': 'https://www.isc.org/downloads/software-support-policy/isc-license/', - 'Magnet link': 'magnet:?xt=urn:btih:b8999bbaf509c08d127678643c515b9ab0836bae&dn=ISC.txt' - }, - 'MPL-2.0':{ - 'Name': 'MPL 2.0', - 'URL': 'http://www.mozilla.org/MPL/2.0', - 'Magnet link': 'magnet:?xt=urn:btih:3877d6d54b3accd4bc32f8a48bf32ebc0901502a&dn=mpl-2.0.txt' - }, - 'UPL-1.0': { - 'Name': 'UPL 1.0', - 'URL': 'https://oss.oracle.com/licenses/upl/', - 'Magnet link': 'magnet:?xt=urn:btih:478974f4d41c3fa84c4befba25f283527fad107d&dn=upl-1.0.txt' - }, - 'WTFPL': { - 'Name': 'WTFPL', - 'URL': 'http://www.wtfpl.net/txt/copying/', - 'Magnet link': 'magnet:?xt=urn:btih:723febf9f6185544f57f0660a41489c7d6b4931b&dn=wtfpl.txt' - }, - 'Unlicense':{ - 'Name': 'Unlicense', - 'URL': 'http://unlicense.org/UNLICENSE', - 'Magnet link': 'magnet:?xt=urn:btih:5ac446d35272cc2e4e85e4325b146d0b7ca8f50c&dn=unlicense.txt' - }, - 'FreeBSD':{ - 'Name': 'FreeBSD', - 'URL': 'http://www.freebsd.org/copyright/freebsd-license.html', - 'Magnet link': 'magnet:?xt=urn:btih:87f119ba0b429ba17a44b4bffcab33165ebdacc0&dn=freebsd.txt' - }, - 'BSD-2-Clause':{ - 'Name': 'FreeBSD (BSD-2-Clause)', - 'URL': 'http://www.freebsd.org/copyright/freebsd-license.html', - 'Magnet link': '' - }, - 'BSD-3-Clause':{ - 'Name': 'Modified BSD (BSD-3-Clause)', - 'URL': 'http://opensource.org/licenses/BSD-3-Clause', - 'Magnet link': 'magnet:?xt=urn:btih:c80d50af7d3db9be66a4d0a86db0286e4fd33292&dn=bsd-3-clause.txt' - }, - 'XFree86-1.1':{ - 'Name': 'XFree86 1.1', - 'URL': 'http://www.xfree86.org/current/LICENSE4.html', - 'Magnet link': 'magnet:?xt=urn:btih:12f2ec9e8de2a3b0002a33d518d6010cc8ab2ae9&dn=xfree86.txt' - } - } + 'ISC': { + licenseName: "The ISC License", + identifier: 'ISC', + canonicalUrl: [ + 'https://www.isc.org/downloads/software-support-policy/isc-license/', + 'magnet:?xt=urn:btih:b8999bbaf509c08d127678643c515b9ab0836bae&dn=ISC.txt' + ], + licenseFragments: [{ text: "Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.", type: type.SHORT }, + { text: "Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.", type: type.SHORT }] + }, + + 'jQueryTools': { + licenseName: "jQuery Tools", + identifier: 'jQueryTools', + canonicalUrl: [], + licenseFragments: [{ + text: 'NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.', + type: type.SHORT + }] + }, + + 'LGPL-2.1': { + licenseName: 'GNU Lesser General Public License, version 2.1', + identifier: 'LGPL-2.1', + canonicalUrl: [ + 'http://www.gnu.org/licenses/lgpl-2.1.html', + 'magnet:?xt=urn:btih:5de60da917303dbfad4f93fb1b985ced5a89eac2&dn=lgpl-2.1.txt' + ], + licenseFragments: [{ text: " is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.", type: type.SHORT }] + }, + + 'LGPL-3.0': { + licenseName: 'GNU Lesser General Public License, version 3', + identifier: 'LGPL-3.0', + canonicalUrl: [ + 'http://www.gnu.org/licenses/lgpl-3.0.html', + 'magnet:?xt=urn:btih:0ef1b8170b3b615170ff270def6427c317705f85&dn=lgpl-3.0.txt' + ], + licenseFragments: [{ text: " is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.", type: type.SHORT }] + }, + + 'MPL-2.0': { + licenseName: 'Mozilla Public License Version 2.0', + identifier: 'MPL-2.0', + canonicalUrl: [ + 'http://www.mozilla.org/MPL/2.0', + 'magnet:?xt=urn:btih:3877d6d54b3accd4bc32f8a48bf32ebc0901502a&dn=mpl-2.0.txt' + ], + licenseFragments: [{ text: "This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.", type: type.SHORT }] + }, + + 'PublicDomain': { + licenseName: 'Public Domain', + identifier: 'PublicDomain', + canonicalUrl: [ + 'magnet:?xt=urn:btih:e95b018ef3580986a04669f1b5879592219e2a7a&dn=public-domain.txt' + ], + licenseFragments: [] + }, + + + 'Unlicense': { + licenseName: 'Unlicense', + identifier: 'Unlicense', + canonicalUrl: [ + 'http://unlicense.org/UNLICENSE', + 'magnet:?xt=urn:btih:5ac446d35272cc2e4e85e4325b146d0b7ca8f50c&dn=unlicense.txt' + ], + licenseFragments: [ + { + text: 'This is free and unencumbered software released into the public domain.', + type: type.SHORT + }, + ] + }, + + 'UPL': { + licenseName: 'Universal Permissive License', + identifier: 'UPL-1.0', + canonicalUrl: [ + 'https://oss.oracle.com/licenses/upl/', + 'magnet:?xt=urn:btih:478974f4d41c3fa84c4befba25f283527fad107d&dn=upl-1.0.txt' + ], + licenseFragments: [{ + text: "The Universal Permissive License (UPL), Version 1.0", + type: type.SHORT + }] + }, + + 'WTFPL': { + licenseName: 'Do What The F*ck You Want To Public License (WTFPL)', + identifier: 'WTFPL', + canonicalUrl: [ + 'http://www.wtfpl.net/txt/copying/', + 'magnet:?xt=urn:btih:723febf9f6185544f57f0660a41489c7d6b4931b&dn=wtfpl.txt' + ], + licenseFragments: [ + { + text: 'DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE', + type: type.SHORT + }, + { + text: '0. You just DO WHAT THE FUCK YOU WANT TO.', + type: type.SHORT + } + ] + }, + + 'X11': { + licenseName: 'X11 License', + identifier: 'X11', + canonicalUrl: [ + 'magnet:?xt=urn:btih:5305d91886084f776adcf57509a648432709a7c7&dn=x11.txt' + ], + licenseFragments: [{ text: "Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.", type: type.SHORT }] + }, + + 'XFree86-1.1': { + licenseName: "XFree86 1.1 License", + identifier: 'XFree86-1.1', + canonicalUrl: [ + 'http://www.xfree86.org/3.3.6/COPYRIGHT2.html#3', + 'http://www.xfree86.org/current/LICENSE4.html', + 'magnet:?xt=urn:btih:12f2ec9e8de2a3b0002a33d518d6010cc8ab2ae9&dn=xfree86.txt' + ], + licenseFragments: [{ text: "All rights reserved.\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution, and in the same place and form as other copyright, license and disclaimer information.\n3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: \"This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors\", in the same place and form as other third-party acknowledgments. Alternately, this acknowledgment may appear in the software itself, in the same form and location as other such third-party acknowledgments.4. Except as contained in this notice, the name of The XFree86 Project, Inc shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The XFree86 Project, Inc.", type: type.SHORT } + ] + }, + + 'Zlib': { + licenseName: 'zlib License', + canonicalUrl: [ + 'https://www.zlib.net/zlib_license.html', + 'https://spdx.org/licenses/Zlib.txt', + 'magnet:?xt=urn:btih:922bd98043fa3daf4f9417e3e8fec8406b1961a3&dn=zlib.txt' + ], + identifier: 'Zlib', + licenseFragments: [] + }, }; -},{}],12:[function(require,module,exports){ +},{}],11:[function(require,module,exports){ /** * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript. * * @@ -2205,15 +2069,16 @@ module.exports=module.exports = { * along with GNU LibreJS. If not, see . */ -var acorn = require('acorn'); -var acornLoose = require('acorn-loose'); -var legacy_license_lib = require("./legacy_license_check.js"); -var {ResponseProcessor} = require("./bg/ResponseProcessor"); -var {Storage, ListStore, hash} = require("./common/Storage"); -var {ListManager} = require("./bg/ListManager"); -var {ExternalLicenses} = require("./bg/ExternalLicenses"); +const acorn = require('acorn'); +const legacy_license_lib = require('./legacy_license_check.js'); +const { ResponseProcessor } = require('./bg/ResponseProcessor'); +const { Storage, ListStore, hash } = require('./common/Storage'); +const { ListManager } = require('./bg/ListManager'); +const { ExternalLicenses } = require('./bg/ExternalLicenses'); +const { licenses } = require('./license_definitions'); +const { patternUtils } = require('./pattern_utils'); -console.log("main_background.js"); +console.log('main_background.js'); /** * If this is true, it evaluates entire scripts instead of returning as soon as it encounters a violation. * @@ -2224,49 +2089,43 @@ var DEBUG = false; // debug the JS evaluation var PRINT_DEBUG = false; // Everything else var time = Date.now(); -function dbg_print(a,b){ - if(PRINT_DEBUG == true){ - console.log("Time spent so far: " + (Date.now() - time)/1000 + " seconds"); - if(b === undefined){ - console.log(a); - } else{ - console.log(a,b); - } - } +function dbg_print(a, b) { + if (PRINT_DEBUG == true) { + console.log('Time spent so far: ' + (Date.now() - time) / 1000 + ' seconds'); + if (b === undefined) { + console.log(a); + } else { + console.log(a, b); + } + } } /* - NONTRIVIAL THINGS: - - Fetch - - XMLhttpRequest - - eval() - - ? - JAVASCRIPT CAN BE FOUND IN: - - Event handlers (onclick, onload, onsubmit, etc.) - - - - - WAYS TO DETERMINE PASS/FAIL: - - "// @license [magnet link] [identifier]" then "// @license-end" (may also use /* comments) - - Automatic whitelist: (http://bzr.savannah.gnu.org/lh/librejs/dev/annotate/head:/data/script_libraries/script-libraries.json_ + NONTRIVIAL THINGS: + - Fetch + - XMLhttpRequest + - eval() + - ? + JAVASCRIPT CAN BE FOUND IN: + - Event handlers (onclick, onload, onsubmit, etc.) + - + - + WAYS TO DETERMINE PASS/FAIL: + - "// @license [magnet link] [identifier]" then "// @license-end" (may also use /* comments) + - Automatic whitelist: (http://bzr.savannah.gnu.org/lh/librejs/dev/annotate/head:/data/script_libraries/script-libraries.json_ */ -var licenses = require("./licenses.json").licenses; // These are objects that it will search for in an initial regex pass over non-free scripts. var reserved_objects = [ - //"document", - //"window", - "fetch", - "XMLHttpRequest", - "chrome", // only on chrome - "browser", // only on firefox - "eval" + //"document", + //"window", + 'fetch', + 'XMLHttpRequest', + 'chrome', // only on chrome + 'browser', // only on firefox + 'eval' ]; -// Generates JSON key for local storage -function get_storage_key(script_name,src_hash){ - return script_name; -} - /* * * Called when something changes the persistent data of the add-on. @@ -2279,24 +2138,16 @@ function get_storage_key(script_name,src_hash){ * with its code to update accordingly * */ -function options_listener(changes, area){ - // The cache must be flushed when settings are changed - // TODO: See if this can be minimized - function flushed(){ - dbg_print("cache flushed"); - } - //var flushingCache = browser.webRequest.handlerBehaviorChanged(flushed); - - - dbg_print("Items updated in area" + area +": "); - - var changedItems = Object.keys(changes); - var changed_items = ""; - for (var i = 0; i < changedItems.length; i++){ - var item = changedItems[i]; - changed_items += item + ","; - } - dbg_print(changed_items); +function options_listener(changes, area) { + dbg_print('Items updated in area' + area + ': '); + + var changedItems = Object.keys(changes); + var changed_items = ''; + for (var i = 0; i < changedItems.length; i++) { + var item = changedItems[i]; + changed_items += item + ','; + } + dbg_print(changed_items); } @@ -2304,26 +2155,26 @@ function options_listener(changes, area){ var activeMessagePorts = {}; var activityReports = {}; async function createReport(initializer) { - if (!(initializer && (initializer.url || initializer.tabId))) { - throw new Error("createReport() needs an URL or a tabId at least"); - } - let template = { - "accepted": [], - "blocked": [], - "blacklisted": [], - "whitelisted": [], - "unknown": [], - }; - template = Object.assign(template, initializer); - let [url] = (template.url || (await browser.tabs.get(initializer.tabId)).url).split("#"); - template.url = url; - template.site = ListStore.siteItem(url); - template.siteStatus = listManager.getStatus(template.site); - let list = {"whitelisted": whitelist, "blacklisted": blacklist}[template.siteStatus]; - if (list) { - template.listedSite = ListManager.siteMatch(template.site, list); - } - return template; + if (!(initializer && (initializer.url || initializer.tabId))) { + throw new Error('createReport() needs an URL or a tabId at least'); + } + let template = { + 'accepted': [], + 'blocked': [], + 'blacklisted': [], + 'whitelisted': [], + 'unknown': [], + }; + template = Object.assign(template, initializer); + let [url] = (template.url || (await browser.tabs.get(initializer.tabId)).url).split('#'); + template.url = url; + template.site = ListStore.siteItem(url); + template.siteStatus = listManager.getStatus(template.site); + let list = { 'whitelisted': whitelist, 'blacklisted': blacklist }[template.siteStatus]; + if (list) { + template.listedSite = ListManager.siteMatch(template.site, list); + } + return template; } /** @@ -2332,9 +2183,9 @@ async function createReport(initializer) { * at the moment. */ async function openReportInTab(data) { - let popupURL = await browser.browserAction.getPopup({}); - let tab = await browser.tabs.create({url: `${popupURL}#fromTab=${data.tabId}`}); - activityReports[tab.id] = await createReport(data); + let popupURL = await browser.browserAction.getPopup({}); + let tab = await browser.tabs.create({ url: `${popupURL}#fromTab=${data.tabId}` }); + activityReports[tab.id] = await createReport(data); } /** @@ -2342,9 +2193,9 @@ async function openReportInTab(data) { * Clears local storage (the persistent data) * */ -function debug_delete_local(){ - browser.storage.local.clear(); - dbg_print("Local storage cleared"); +function debug_delete_local() { + browser.storage.local.clear(); + dbg_print('Local storage cleared'); } /** @@ -2352,16 +2203,16 @@ function debug_delete_local(){ * Prints local storage (the persistent data) as well as the temporary popup object * */ -function debug_print_local(){ - function storage_got(items){ - console.log("%c Local storage: ", 'color: red;'); - for(var i in items){ - console.log("%c "+i+" = "+items[i], 'color: blue;'); - } - } - console.log("%c Variable 'activityReports': ", 'color: red;'); - console.log(activityReports); - browser.storage.local.get(storage_got); +function debug_print_local() { + function storage_got(items) { + console.log('%c Local storage: ', 'color: red;'); + for (var i in items) { + console.log('%c ' + i + ' = ' + items[i], 'color: blue;'); + } + } + console.log('%c Variable \'activityReports\': ', 'color: red;'); + console.log(activityReports); + browser.storage.local.get(storage_got); } /** @@ -2379,25 +2230,25 @@ function debug_print_local(){ * Make sure it will use the right URL when refering to a certain script. * */ -async function updateReport(tabId, oldReport, updateUI = false){ - let {url} = oldReport; - let newReport = await createReport({url, tabId}); - for (let property of Object.keys(oldReport)) { - let entries = oldReport[property]; - if (!Array.isArray(entries)) continue; - let defValue = property === "accepted" || property === "blocked" ? property : "unknown"; - for (let script of entries) { - let status = listManager.getStatus(script[0], defValue); - if (Array.isArray(newReport[status])) newReport[status].push(script); - } - } - activityReports[tabId] = newReport; - if (browser.sessions) browser.sessions.setTabValue(tabId, url, newReport); - dbg_print(newReport); - if (updateUI && activeMessagePorts[tabId]) { - dbg_print(`[TABID: ${tabId}] Sending script blocking report directly to browser action.`); - activeMessagePorts[tabId].postMessage({show_info: newReport}); - } +async function updateReport(tabId, oldReport, updateUI = false) { + let { url } = oldReport; + let newReport = await createReport({ url, tabId }); + for (let property of Object.keys(oldReport)) { + let entries = oldReport[property]; + if (!Array.isArray(entries)) continue; + let defValue = property === 'accepted' || property === 'blocked' ? property : 'unknown'; + for (let script of entries) { + let status = listManager.getStatus(script[0], defValue); + if (Array.isArray(newReport[status])) newReport[status].push(script); + } + } + activityReports[tabId] = newReport; + if (browser.sessions) browser.sessions.setTabValue(tabId, url, newReport); + dbg_print(newReport); + if (updateUI && activeMessagePorts[tabId]) { + dbg_print(`[TABID: ${tabId}] Sending script blocking report directly to browser action.`); + activeMessagePorts[tabId].postMessage({ show_info: newReport }); + } } /** @@ -2420,70 +2271,67 @@ async function updateReport(tabId, oldReport, updateUI = false){ * Make sure it will use the right URL when refering to a certain script. * */ -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) { - actionValue = action[type]; - break; - } - } - if (!actionValue) { - console.debug("Something wrong with action", action); - return ""; - } +async function addReportEntry(tabId, 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) { + actionValue = action[type]; + break; + } + } + if (!actionValue) { + console.debug('Something wrong with action', action); + return ''; + } - // Search unused data for the given entry - function isNew(entries, item) { - for (let e of entries) { - if (e[0] === item) return false; - } - return true; - } + // Search unused data for the given entry + function isNew(entries, item) { + for (let e of entries) { + if (e[0] === item) return false; + } + return true; + } - let entryType; - let scriptName = actionValue[0]; - try { - entryType = listManager.getStatus(scriptName, type); - let entries = report[entryType]; - if(isNew(entries, scriptName)){ - dbg_print(activityReports); - dbg_print(activityReports[tabId]); - dbg_print(entryType); - entries.push(actionValue); - } - } catch (e) { - console.error("action %o, type %s, entryType %s", action, type, entryType, e); - entryType = "unknown"; - } + let entryType; + let scriptName = actionValue[0]; + try { + entryType = listManager.getStatus(scriptName, type); + let entries = report[entryType]; + if (isNew(entries, scriptName)) { + dbg_print(activityReports); + dbg_print(activityReports[tabId]); + dbg_print(entryType); + entries.push(actionValue); + } + } catch (e) { + console.error('action %o, type %s, entryType %s', action, type, entryType, e); + entryType = 'unknown'; + } - if (activeMessagePorts[tabId]) { - try { - activeMessagePorts[tabId].postMessage({show_info: report}); - } catch(e) { - } - } + if (activeMessagePorts[tabId]) { + activeMessagePorts[tabId].postMessage({ show_info: report }); + } - if (browser.sessions) browser.sessions.setTabValue(tabId, report.url, report); - updateBadge(tabId, report); - return entryType; + if (browser.sessions) browser.sessions.setTabValue(tabId, report.url, report); + updateBadge(tabId, report); + return entryType; } -function get_domain(url){ - var domain = url.replace('http://','').replace('https://','').split(/[/?#]/)[0]; - if(url.indexOf("http://") == 0){ - domain = "http://" + domain; - } - else if(url.indexOf("https://") == 0){ - domain = "https://" + domain; - } - domain = domain + "/"; - domain = domain.replace(/ /g,""); - return domain; +function get_domain(url) { + var domain = url.replace('http://', '').replace('https://', '').split(/[/?#]/)[0]; + if (url.indexOf('http://') == 0) { + domain = 'http://' + domain; + } + else if (url.indexOf('https://') == 0) { + domain = 'https://' + domain; + } + domain = domain + '/'; + domain = domain.replace(/ /g, ''); + return domain; } /** @@ -2491,84 +2339,83 @@ function get_domain(url){ * This is the callback where the content scripts of the browser action will contact the background script. * */ -var portFromCS; async function connected(p) { - if(p.name === "contact_finder"){ - // style the contact finder panel - await browser.tabs.insertCSS(p.sender.tab.id, { - file: "/content/dialog.css", - cssOrigin: "user", - matchAboutBlank: true, - allFrames: true - }); - - // Send a message back with the relevant settings - p.postMessage(await browser.storage.local.get(["prefs_subject", "prefs_body"])); - return; - } - p.onMessage.addListener(async function(m) { - var update = false; - var contact_finder = false; - - for (let action of ["whitelist", "blacklist", "forget"]) { - if (m[action]) { - let [key] = m[action]; - if (m.site) { - key = ListStore.siteItem(m.site); - } else { - key = ListStore.inlineItem(key) || key; - } - await listManager[action](key); - update = true; - } - } - - if(m.report_tab){ - openReportInTab(m.report_tab); - } - // a debug feature - if(m["printlocalstorage"] !== undefined){ - console.log("Print local storage"); - debug_print_local(); - } - // invoke_contact_finder - if(m["invoke_contact_finder"] !== undefined){ - contact_finder = true; - await injectContactFinder(); - } - // a debug feature (maybe give the user an option to do this?) - if(m["deletelocalstorage"] !== undefined){ - console.log("Delete local storage"); - debug_delete_local(); - } - - let tabs = await browser.tabs.query({active: true, currentWindow: true}); - - if(contact_finder){ - let tab = tabs.pop(); - dbg_print(`[TABID:${tab.id}] Injecting contact finder`); - //inject_contact_finder(tabs[0]["id"]); - } - if (update || m.update && activityReports[m.tabId]) { - let tabId = "tabId" in m ? m.tabId : tabs.pop().id; - dbg_print(`%c updating tab ${tabId}`, "color: red;"); - activeMessagePorts[tabId] = p; - await updateReport(tabId, activityReports[tabId], true); - } else { - for(let tab of tabs) { - if(activityReports[tab.id]){ - // If we have some data stored here for this tabID, send it - dbg_print(`[TABID: ${tab.id}] Sending stored data associated with browser action'`); - p.postMessage({"show_info": activityReports[tab.id]}); - } else{ - // create a new entry - let report = activityReports[tab.id] = await createReport({"url": tab.url, tabId: tab.id}); - p.postMessage({show_info: report}); - dbg_print(`[TABID: ${tab.id}] No data found, creating a new entry for this window.`); - } - } - } - }); + if (p.name === 'contact_finder') { + // style the contact finder panel + await browser.tabs.insertCSS(p.sender.tab.id, { + file: '/content/dialog.css', + cssOrigin: 'user', + matchAboutBlank: true, + allFrames: true + }); + + // Send a message back with the relevant settings + p.postMessage(await browser.storage.local.get(['prefs_subject', 'prefs_body'])); + return; + } + p.onMessage.addListener(async function(m) { + var update = false; + var contact_finder = false; + + for (let action of ['whitelist', 'blacklist', 'forget']) { + if (m[action]) { + let [key] = m[action]; + if (m.site) { + key = ListStore.siteItem(m.site); + } else { + key = ListStore.inlineItem(key) || key; + } + await listManager[action](key); + update = true; + } + } + + if (m.report_tab) { + openReportInTab(m.report_tab); + } + // a debug feature + if (m['printlocalstorage'] !== undefined) { + console.log('Print local storage'); + debug_print_local(); + } + // invoke_contact_finder + if (m['invoke_contact_finder'] !== undefined) { + contact_finder = true; + await injectContactFinder(); + } + // a debug feature (maybe give the user an option to do this?) + if (m['deletelocalstorage'] !== undefined) { + console.log('Delete local storage'); + debug_delete_local(); + } + + let tabs = await browser.tabs.query({ active: true, currentWindow: true }); + + if (contact_finder) { + let tab = tabs.pop(); + dbg_print(`[TABID:${tab.id}] Injecting contact finder`); + //inject_contact_finder(tabs[0]["id"]); + } + if (update || m.update && activityReports[m.tabId]) { + let tabId = 'tabId' in m ? m.tabId : tabs.pop().id; + dbg_print(`%c updating tab ${tabId}`, 'color: red;'); + activeMessagePorts[tabId] = p; + await updateReport(tabId, activityReports[tabId], true); + } else { + for (let tab of tabs) { + if (activityReports[tab.id]) { + // If we have some data stored here for this tabID, send it + dbg_print(`[TABID: ${tab.id}] Sending stored data associated with browser action'`); + p.postMessage({ 'show_info': activityReports[tab.id] }); + } else { + // create a new entry + let report = activityReports[tab.id] = await createReport({ 'url': tab.url, tabId: tab.id }); + p.postMessage({ show_info: report }); + dbg_print(`[TABID: ${tab.id}] No data found, creating a new entry for this window.`); + } + } + } + }); } /** @@ -2577,15 +2424,15 @@ async function connected(p) { * Delete the info we are storing about this tab if there is any. * */ -function delete_removed_tab_info(tab_id, remove_info){ - dbg_print("[TABID:"+tab_id+"]"+"Deleting stored info about closed tab"); - if(activityReports[tab_id] !== undefined){ - delete activityReports[tab_id]; - } - if(activeMessagePorts[tab_id] !== undefined){ - delete activeMessagePorts[tab_id]; - } - ExternalLicenses.purgeCache(tab_id); +function delete_removed_tab_info(tab_id, _) { + dbg_print('[TABID:' + tab_id + ']' + 'Deleting stored info about closed tab'); + if (activityReports[tab_id] !== undefined) { + delete activityReports[tab_id]; + } + if (activeMessagePorts[tab_id] !== undefined) { + delete activeMessagePorts[tab_id]; + } + ExternalLicenses.purgeCache(tab_id); } /** @@ -2596,150 +2443,131 @@ function delete_removed_tab_info(tab_id, remove_info){ * */ -async function onTabUpdated(tabId, changedInfo, tab) { - let [url] = tab.url.split("#"); - let report = activityReports[tabId]; - if (!(report && report.url === url)) { - let cache = browser.sessions && - await browser.sessions.getTabValue(tabId, url) || null; - // on session restore tabIds may change - if (cache && cache.tabId !== tabId) cache.tabId = tabId; - updateBadge(tabId, activityReports[tabId] = cache); - } +async function onTabUpdated(tabId, _, tab) { + let [url] = tab.url.split('#'); + let report = activityReports[tabId]; + if (!(report && report.url === url)) { + let cache = browser.sessions && + await browser.sessions.getTabValue(tabId, url) || null; + // on session restore tabIds may change + if (cache && cache.tabId !== tabId) cache.tabId = tabId; + updateBadge(tabId, activityReports[tabId] = cache); + } } -async function onTabActivated({tabId}) { - await onTabUpdated(tabId, {}, await browser.tabs.get(tabId)); +async function onTabActivated({ tabId }) { + await onTabUpdated(tabId, {}, await browser.tabs.get(tabId)); } /* *********************************************************************************************** */ -var fname_data = require("./fname_data.json").fname_data; +var fname_data = require('./fname_data.json').fname_data; //************************this part can be tested in the HTML file index.html's script test.js**************************** -function full_evaluate(script){ - var res = true; - if(script === undefined || script == ""){ - return [true,"Harmless null script"]; - } - - var ast = acornLoose.parse(script).body[0]; - - var flag = false; - var amtloops = 0; - - var loopkeys = {"for":true,"if":true,"while":true,"switch":true}; - var operators = {"||":true,"&&":true,"=":true,"==":true,"++":true,"--":true,"+=":true,"-=":true,"*":true}; - try{ - var tokens = acorn.tokenizer(script); - }catch(e){ - console.warn("Tokenizer could not be initiated (probably invalid code)"); - return [false,"Tokenizer could not be initiated (probably invalid code)"]; - } - 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"); - } - - /** - * Given the end of an identifer token, it tests for bracket suffix notation - */ - function being_called(end){ - var i = 0; - while(script.charAt(end+i).match(/\s/g) !== null){ - i++; - if(i >= script.length-1){ - return false; - } - } - - return script.charAt(end+i) == "("; - } - /** - * Given the end of an identifer token, it tests for parentheses - */ - function is_bsn(end){ - var i = 0; - while(script.charAt(end+i).match(/\s/g) !== null){ - i++; - if(i >= script.length-1){ - return false; - } - } - return script.charAt(end+i) == "["; - } - var error_count = 0; - var defines_functions = false; - while(toke !== undefined && toke.type != acorn.tokTypes.eof){ - if(toke.type.keyword !== undefined){ - //dbg_print("Keyword:"); - //dbg_print(toke); - - // This type of loop detection ignores functional loop alternatives and ternary operators - - if(toke.type.keyword == "function"){ - dbg_print("%c NOTICE: Function declaration.","color:green"); - defines_functions = true; - } - - if(loopkeys[toke.type.keyword] !== undefined){ - amtloops++; - if(amtloops > 3){ - dbg_print("%c NONTRIVIAL: Too many loops/conditionals.","color:red"); - if(DEBUG == false){ - return [false,"NONTRIVIAL: Too many loops/conditionals."]; - } - } - } - }else if(toke.value !== undefined && operators[toke.value] !== undefined){ - // It's just an operator. Javascript doesn't have operator overloading so it must be some - // kind of primitive (I.e. a number) - }else if(toke.value !== undefined){ - var status = fname_data[toke.value]; - if(status === true){ // is the identifier banned? - dbg_print("%c NONTRIVIAL: nontrivial token: '"+toke.value+"'","color:red"); - if(DEBUG == false){ - return [false,"NONTRIVIAL: nontrivial token: '"+toke.value+"'"]; - } - }else if(status === false){// is the identifier not banned? - // Is there bracket suffix notation? - if(is_bsn(toke.end)){ - dbg_print("%c NONTRIVIAL: Bracket suffix notation on variable '"+toke.value+"'","color:red"); - if(DEBUG == false){ - return [false,"%c NONTRIVIAL: Bracket suffix notation on variable '"+toke.value+"'"]; - } - } - }else if(status === undefined){// is the identifier user defined? - // Is there bracket suffix notation? - if(is_bsn(toke.end)){ - dbg_print("%c NONTRIVIAL: Bracket suffix notation on variable '"+toke.value+"'","color:red"); - if(DEBUG == false){ - return [false,"NONTRIVIAL: Bracket suffix notation on variable '"+toke.value+"'"]; - } - } - }else{ - dbg_print("trivial token:"+toke.value); - } - } - // If not a keyword or an identifier it's some kind of operator, field parenthesis, brackets - try{ - toke = tokens.getToken(); - }catch(e){ - dbg_print("Denied script because it cannot be parsed."); - return [false,"NONTRIVIAL: Cannot be parsed. This could mean it is a 404 error."]; - } - } - - dbg_print("%cAppears to be trivial.","color:green;"); - if (defines_functions === true) - return [true,"Script appears to be trivial but defines functions."]; - else - return [true,"Script appears to be trivial."]; +function full_evaluate(script) { + if (script === undefined || script == '') { + return [true, 'Harmless null script']; + } + + var amtloops = 0; + + var loopkeys = { 'for': true, 'if': true, 'while': true, 'switch': true }; + var operators = { '||': true, '&&': true, '=': true, '==': true, '++': true, '--': true, '+=': true, '-=': true, '*': true }; + try { + var tokens = acorn.tokenizer(script); + } catch (e) { + console.warn('Tokenizer could not be initiated (probably invalid code)'); + return [false, 'Tokenizer could not be initiated (probably invalid code)']; + } + 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'); + } + + /** + * Given the end of an identifer token, it tests for parentheses + */ + function is_bsn(end) { + var i = 0; + while (script.charAt(end + i).match(/\s/g) !== null) { + i++; + if (i >= script.length - 1) { + return false; + } + } + return script.charAt(end + i) == '['; + } + var defines_functions = false; + while (toke !== undefined && toke.type != acorn.tokTypes.eof) { + if (toke.type.keyword !== undefined) { + //dbg_print("Keyword:"); + //dbg_print(toke); + + // This type of loop detection ignores functional loop alternatives and ternary operators + + if (toke.type.keyword == 'function') { + dbg_print('%c NOTICE: Function declaration.', 'color:green'); + defines_functions = true; + } + + if (loopkeys[toke.type.keyword] !== undefined) { + amtloops++; + if (amtloops > 3) { + dbg_print('%c NONTRIVIAL: Too many loops/conditionals.', 'color:red'); + if (DEBUG == false) { + return [false, 'NONTRIVIAL: Too many loops/conditionals.']; + } + } + } + } else if (toke.value !== undefined && operators[toke.value] !== undefined) { + // It's just an operator. Javascript doesn't have operator overloading so it must be some + // kind of primitive (I.e. a number) + } else if (toke.value !== undefined) { + var status = fname_data[toke.value]; + if (status === true) { // is the identifier banned? + dbg_print('%c NONTRIVIAL: nontrivial token: \'' + toke.value + '\'', 'color:red'); + if (DEBUG == false) { + return [false, 'NONTRIVIAL: nontrivial token: \'' + toke.value + '\'']; + } + } else if (status === false) {// is the identifier not banned? + // Is there bracket suffix notation? + if (is_bsn(toke.end)) { + dbg_print('%c NONTRIVIAL: Bracket suffix notation on variable \'' + toke.value + '\'', 'color:red'); + if (DEBUG == false) { + return [false, '%c NONTRIVIAL: Bracket suffix notation on variable \'' + toke.value + '\'']; + } + } + } else if (status === undefined) {// is the identifier user defined? + // Is there bracket suffix notation? + if (is_bsn(toke.end)) { + dbg_print('%c NONTRIVIAL: Bracket suffix notation on variable \'' + toke.value + '\'', 'color:red'); + if (DEBUG == false) { + return [false, 'NONTRIVIAL: Bracket suffix notation on variable \'' + toke.value + '\'']; + } + } + } else { + dbg_print('trivial token:' + toke.value); + } + } + // If not a keyword or an identifier it's some kind of operator, field parenthesis, brackets + try { + toke = tokens.getToken(); + } catch (e) { + dbg_print('Denied script because it cannot be parsed.'); + return [false, 'NONTRIVIAL: Cannot be parsed. This could mean it is a 404 error.']; + } + } + + dbg_print('%cAppears to be trivial.', 'color:green;'); + if (defines_functions === true) + return [true, 'Script appears to be trivial but defines functions.']; + else + return [true, 'Script appears to be trivial.']; } @@ -2756,65 +2584,57 @@ function full_evaluate(script){ * It returns an array of [flag (boolean, false if "bad"), reason (string, human readable report)] * */ -function evaluate(script,name){ - function reserved_object_regex(object){ - var arith_operators = "\\+\\-\\*\\/\\%\\="; - var scope_chars = "\{\}\]\[\(\)\,"; - var trailing_chars = "\s*"+"\(\.\["; - return new RegExp("(?:[^\\w\\d]|^|(?:"+arith_operators+"))"+object+'(?:\\s*?(?:[\\;\\,\\.\\(\\[])\\s*?)',"g"); - } - reserved_object_regex("window"); - var all_strings = new RegExp('".*?"'+"|'.*?'","gm"); - var ml_comment = /\/\*([\s\S]+?)\*\//g; - var il_comment = /\/\/.+/gm; - var bracket_pairs = /\[.+?\]/g; - var temp = script.replace(/'.+?'+/gm,"'string'"); - temp = temp.replace(/".+?"+/gm,'"string"'); - temp = temp.replace(ml_comment,""); - temp = temp.replace(il_comment,""); - dbg_print("%c ------evaluation results for "+ name +"------","color:white"); - dbg_print("Script accesses reserved objects?"); - var flag = true; - var reason = "" - // This is where individual "passes" are made over the code - for(var i = 0; i < reserved_objects.length; i++){ - var res = reserved_object_regex(reserved_objects[i]).exec(temp); - if(res != null){ - dbg_print("%c fail","color:red;"); - flag = false; - reason = "Script uses a reserved object (" + reserved_objects[i] + ")"; - } - } - if(flag){ - dbg_print("%c pass","color:green;"); - } else{ - return [flag,reason]; - } +function evaluate(script, name) { + function reserved_object_regex(object) { + var arith_operators = '\\+\\-\\*\\/\\%\\='; + return new RegExp('(?:[^\\w\\d]|^|(?:' + arith_operators + '))' + object + '(?:\\s*?(?:[\\;\\,\\.\\(\\[])\\s*?)', 'g'); + } + reserved_object_regex('window'); + const ml_comment = /\/\*([\s\S]+?)\*\//g; + const il_comment = /\/\/.+/gm; + var temp = script.replace(/'.+?'+/gm, '\'string\''); + temp = temp.replace(/".+?"+/gm, '"string"'); + temp = temp.replace(ml_comment, ''); + temp = temp.replace(il_comment, ''); + dbg_print('%c ------evaluation results for ' + name + '------', 'color:white'); + dbg_print('Script accesses reserved objects?'); + var flag = true; + var reason = '' + // This is where individual "passes" are made over the code + for (var i = 0; i < reserved_objects.length; i++) { + var res = reserved_object_regex(reserved_objects[i]).exec(temp); + if (res != null) { + dbg_print('%c fail', 'color:red;'); + flag = false; + reason = 'Script uses a reserved object (' + reserved_objects[i] + ')'; + } + } + if (flag) { + dbg_print('%c pass', 'color:green;'); + } else { + return [flag, reason]; + } - return full_evaluate(script); + return full_evaluate(script); } function validateLicense(matches) { - if (!(Array.isArray(matches) && matches.length >= 4)){ - return [false, "Malformed or unrecognized license tag."]; - } + if (!(Array.isArray(matches) && matches.length >= 4)) { + return [false, 'Malformed or unrecognized license tag.']; + } - let [all, tag, first, second] = matches; - - for (let key in licenses){ - // Match by id on first or second parameter, ignoring case - if (key.toLowerCase() === first.toLowerCase() || - key.toLowerCase() === second.toLowerCase()) { - return [true, `Recognized license: "${licenses[key]['Name']}" `]; - } - // Match by link on first parameter (legacy) - if (licenses[key]["Magnet link"] === first.replace("&","&") || - licenses[key]["URL"] === first.replace("&","&")) { - return [true, `Recognized license: "${licenses[key]['Name']}".`]; - } - } - return [false, `Unrecognized license tag: "${all}"`]; + const [all, first] = [matches[0], matches[2].replace('&', '&')]; + + for (const key in licenses) { + // Match by link on first parameter (legacy) + for (const url of licenses[key].canonicalUrl) { + if (first === url || first === url.replace('^http://', 'https://')) { + return [true, `Recognized license: "${licenses[key].licenseName}".`]; + } + } + } + return [false, `Unrecognized license tag: "${all}"`]; } @@ -2829,186 +2649,191 @@ function validateLicense(matches) { * reason text * ] */ -function license_read(scriptSrc, name, external = false){ +function license_read(scriptSrc, name, external = false) { - let license = legacy_license_lib.check(scriptSrc); - if (license){ - return [true, scriptSrc, `Licensed under: ${license}`]; - } - if (listManager.builtInHashes.has(hash(scriptSrc))){ - return [true, scriptSrc, "Common script known to be free software."]; - } + const license = legacy_license_lib.check(scriptSrc); + if (license) { + return [true, scriptSrc, `Licensed under: ${license}`]; + } + if (listManager.builtInHashes.has(hash(scriptSrc))) { + return [true, scriptSrc, 'Common script known to be free software.']; + } - let editedSrc = ""; - let uneditedSrc = scriptSrc.trim(); - let reason = uneditedSrc ? "" : "Empty source."; - let partsDenied = false; - let partsAccepted = false; - - function checkTriviality(s) { - if (!s.trim()) { - return true; // empty, ignore it - } - let [trivial, message] = external ? - [false, "External script with no known license"] - : evaluate(s, name); - if (trivial) { - partsAccepted = true; - editedSrc += s; - } else { - partsDenied = true; - if (s.startsWith("javascript:")) - editedSrc += `# LIBREJS BLOCKED: ${message}`; - else - editedSrc += `/*\nLIBREJS BLOCKED: ${message}\n*/`; - } - reason += `\n${message}`; - return trivial; - } + let editedSrc = ''; + let uneditedSrc = scriptSrc.trim(); + let reason = uneditedSrc ? '' : 'Empty source.'; + let partsDenied = false; + let partsAccepted = false; + + function checkTriviality(s) { + if (!patternUtils.removeJsComments(s).trim()) { + return true; // empty, ignore it + } + const [trivial, message] = external ? + [false, 'External script with no known license'] + : evaluate(s, name); + if (trivial) { + partsAccepted = true; + editedSrc += s; + } else { + partsDenied = true; + if (s.startsWith('javascript:')) + editedSrc += `# LIBREJS BLOCKED: ${message}`; + else + editedSrc += `/*\nLIBREJS BLOCKED: ${message}\n*/`; + } + reason += `\n${message}`; + return trivial; + } - while (uneditedSrc) { - let openingMatch = /\/[\/\*]\s*?(@license)\s+(\S+)\s+(\S+)\s*$/mi.exec(uneditedSrc); - if (!openingMatch) { // no license found, check for triviality - checkTriviality(uneditedSrc); - break; - } - - let openingIndex = openingMatch.index; - if (openingIndex) { - // let's check the triviality of the code before the license tag, if any - checkTriviality(uneditedSrc.substring(0, openingIndex)); - } - // let's check the actual license - uneditedSrc = uneditedSrc.substring(openingIndex); - - let closureMatch = /\/([*/])\s*@license-end\b[^*/\n]*/i.exec(uneditedSrc); - if (!closureMatch) { - let msg = "ERROR: @license with no @license-end"; - return [false, `\n/*\n ${msg} \n*/\n`, msg]; - } - - let closureEndIndex = closureMatch.index + closureMatch[0].length; - let commentEndOffset = uneditedSrc.substring(closureEndIndex).indexOf(closureMatch[1] === "*" ? "*/" : "\n"); - if (commentEndOffset !== -1) { - closureEndIndex += commentEndOffset; - } - - let [licenseOK, message] = validateLicense(openingMatch); - if(licenseOK) { - editedSrc += uneditedSrc.substr(0, closureEndIndex); - partsAccepted = true; - } else { - editedSrc += `\n/*\n${message}\n*/\n`; - partsDenied = true; - } - reason += `\n${message}`; - - // trim off everything we just evaluated - uneditedSrc = uneditedSrc.substring(closureEndIndex).trim(); - } + while (uneditedSrc) { + const openingMatch = /\/[/*]\s*?(@license)\s+(\S+)\s+(\S+).*$/mi.exec(uneditedSrc); + if (!openingMatch) { // no license found, check for triviality + checkTriviality(uneditedSrc); + break; + } - if(partsDenied) { - if (partsAccepted) { - reason = `Some parts of the script have been disabled (check the source for details).\n^--- ${reason}`; - } - return [false, editedSrc, reason]; - } + const openingIndex = openingMatch.index; + if (openingIndex) { + // let's check the triviality of the code before the license tag, if any + checkTriviality(uneditedSrc.substring(0, openingIndex)); + } + // let's check the actual license + uneditedSrc = uneditedSrc.substring(openingIndex); - return [true, scriptSrc, reason]; -} + const closureMatch = + /\/([*/])\s*@license-end\s*(\*\/)?/mi.exec(uneditedSrc); + if (!closureMatch) { + const msg = 'ERROR: @license with no @license-end'; + return [false, `\n/*\n ${msg} \n*/\n`, msg]; + } -/* *********************************************************************************************** */ -// TODO: Test if this script is being loaded from another domain compared to activityReports[tabid]["url"] + let closureEndIndex = closureMatch.index + closureMatch[0].length; + const commentEndOffset = uneditedSrc.substring(closureEndIndex).indexOf(closureMatch[1] === '*' ? '*/' : '\n'); + if (commentEndOffset !== -1) { + closureEndIndex += commentEndOffset; + } -/** -* Asynchronous function, returns the final edited script as a string, -* or an array containing it and the index, if the latter !== -1 + const [licenseOK, message] = validateLicense(openingMatch); + if (licenseOK) { + editedSrc += uneditedSrc.substr(0, closureEndIndex); + partsAccepted = true; + } else { + editedSrc += `\n/*\n${message}\n*/\n`; + partsDenied = true; + } + reason += `\n${message}`; + + // trim off everything we just evaluated + uneditedSrc = uneditedSrc.substring(closureEndIndex).trim(); + } + + if (partsDenied) { + if (partsAccepted) { + reason = `Some parts of the script have been disabled (check the source for details).\n^--- ${reason}`; + } + return [false, editedSrc, reason]; + } + + return [true, scriptSrc, reason]; +} + +/* *********************************************************************************************** */ +// TODO: Test if this script is being loaded from another domain compared to activityReports[tabid]["url"] + +/** +* Asynchronous function, returns the final edited script as a string, +* or an array containing it and the index, if the latter !== -1 */ async function get_script(response, url, tabId = -1, whitelisted = false, index = -1) { - function result(scriptSource) { - return index === -1 ? scriptSource : [scriptSource, index]; - } + function result(scriptSource) { + return index === -1 ? scriptSource : [scriptSource, index]; + } - let scriptName = url.split("/").pop(); - if (whitelisted) { - if (tabId !== -1) { - let site = ListManager.siteMatch(url, whitelist); - // Accept without reading script, it was explicitly whitelisted - let reason = site - ? `All ${site} whitelisted by user` - : "Address whitelisted by user"; - addReportEntry(tabId, url, {"whitelisted": [site || url, reason], url}); - } - if (response.startsWith("javascript:")) - return result(response); - else - return result(`/* LibreJS: script whitelisted by user preference. */\n${response}`); - } + let scriptName = url.split('/').pop(); + if (whitelisted) { + if (tabId !== -1) { + let site = ListManager.siteMatch(url, whitelist); + // Accept without reading script, it was explicitly whitelisted + let reason = site + ? `All ${site} whitelisted by user` + : 'Address whitelisted by user'; + addReportEntry(tabId, { 'whitelisted': [site || url, reason], url }); + } + if (response.startsWith('javascript:')) + return result(response); + else + return result(`/* LibreJS: script whitelisted by user preference. */\n${response}`); + } - let [verdict, editedSource, reason] = license_read(response, scriptName, index === -2); + let [verdict, editedSource, reason] = license_read(response, scriptName, index === -2); - if (tabId < 0) { - return result(verdict ? response : editedSource); - } + if (tabId < 0) { + return result(verdict ? response : editedSource); + } - let sourceHash = hash(response); - let domain = get_domain(url); - let report = activityReports[tabId] || (activityReports[tabId] = await createReport({tabId})); - updateBadge(tabId, report, !verdict); - let category = await addReportEntry(tabId, sourceHash, {"url": domain, [verdict ? "accepted" : "blocked"]: [url, reason]}); - switch(category) { - case "blacklisted": - editedSource = `/* LibreJS: script ${category} by user. */`; - return result(response.startsWith("javascript:") - ? `javascript:void(${encodeURIComponent(editedSource)})` : editedSource); - case "whitelisted": - return result(response.startsWith("javascript:") - ? response : `/* LibreJS: script ${category} by user. */\n${response}`); - default: - let scriptSource = verdict ? response : editedSource; - return result(response.startsWith("javascript:") - ? (verdict ? scriptSource : `javascript:void(/* ${scriptSource} */)`) - : `/* LibreJS: script ${category}. */\n${scriptSource}` - ); - } + let domain = get_domain(url); + let report = activityReports[tabId] || (activityReports[tabId] = await createReport({ tabId })); + updateBadge(tabId, report, !verdict); + let category = await addReportEntry(tabId, { 'url': domain, [verdict ? 'accepted' : 'blocked']: [url, reason] }); + switch (category) { + case 'blacklisted': { + editedSource = `/* LibreJS: script ${category} by user. */`; + return result(response.startsWith('javascript:') + ? `javascript:void(${encodeURIComponent(editedSource)})` : editedSource); + } + case 'whitelisted': { + return result(response.startsWith('javascript:') + ? response : `/* LibreJS: script ${category} by user. */\n${response}`); + } + default: { + let scriptSource = verdict ? response : editedSource; + return result(response.startsWith('javascript:') + ? (verdict ? scriptSource : `javascript:void(/* ${scriptSource} */)`) + : `/* LibreJS: script ${category}. */\n${scriptSource}` + ); + } + } } function updateBadge(tabId, report = null, forceRed = false) { - let blockedCount = report ? report.blocked.length + report.blacklisted.length : 0; - let [text, color] = blockedCount > 0 || forceRed - ? [blockedCount && blockedCount.toString() || "!" , "red"] : ["✓", "green"] - let {browserAction} = browser; - if ("setBadgeText" in browserAction) { - browserAction.setBadgeText({text, tabId}); - browserAction.setBadgeBackgroundColor({color, tabId}); - } else { - // Mobile - browserAction.setTitle({title: `LibreJS (${text})`, tabId}); - } + let blockedCount = report ? report.blocked.length + report.blacklisted.length : 0; + let [text, color] = blockedCount > 0 || forceRed + ? [blockedCount && blockedCount.toString() || '!', 'red'] : ['✓', 'green'] + let { browserAction } = browser; + if ('setBadgeText' in browserAction) { + browserAction.setBadgeText({ text, tabId }); + browserAction.setBadgeBackgroundColor({ color, tabId }); + } else { + // Mobile + browserAction.setTitle({ title: `LibreJS (${text})`, tabId }); + } } function blockGoogleAnalytics(request) { - let {url} = request; - let res = {}; - if (url === 'https://www.google-analytics.com/analytics.js' || - /^https:\/\/www\.google\.com\/analytics\/[^#]/.test(url) - ) { - res.cancel = true; - } - return res; + let { url } = request; + let res = {}; + if (url === 'https://www.google-analytics.com/analytics.js' || + /^https:\/\/www\.google\.com\/analytics\/[^#]/.test(url) + ) { + res.cancel = true; + } + return res; } -async function blockBlacklistedScripts(request) { - let {url, tabId, documentUrl} = request; - url = ListStore.urlItem(url); - let status = listManager.getStatus(url); - if (status !== "blacklisted") return {}; - let blacklistedSite = ListManager.siteMatch(url, blacklist); - await addReportEntry(tabId, url, {url: documentUrl, - "blacklisted": [url, /\*/.test(blacklistedSite) ? `User blacklisted ${blacklistedSite}` : "Blacklisted by user"]}); - return {cancel: true}; +async function blockBlacklistedScripts(request) { + let { url, tabId, documentUrl } = request; + url = ListStore.urlItem(url); + let status = listManager.getStatus(url); + if (status !== 'blacklisted') return {}; + let blacklistedSite = ListManager.siteMatch(url, blacklist); + await addReportEntry(tabId, { + url: documentUrl, + 'blacklisted': [url, /\*/.test(blacklistedSite) ? `User blacklisted ${blacklistedSite}` : 'Blacklisted by user'] + }); + return { cancel: true }; } /** @@ -3018,91 +2843,93 @@ async function blockBlacklistedScripts(request) { */ var ResponseHandler = { - /** - * Enforce white/black lists for url/site early (hashes will be handled later) - */ - async pre(response) { - let {request} = response; - let {url, type, tabId, frameId, documentUrl} = request; - - let fullUrl = url; - url = ListStore.urlItem(url); - let site = ListStore.siteItem(url); - - let blacklistedSite = ListManager.siteMatch(site, blacklist); - let blacklisted = blacklistedSite || blacklist.contains(url); - let topUrl = type === "sub_frame" && request.frameAncestors && request.frameAncestors.pop() || documentUrl; - - if (blacklisted) { - if (type === "script") { - // this shouldn't happen, because we intercept earlier in blockBlacklistedScripts() - return ResponseProcessor.REJECT; - } - if (type === "main_frame") { // we handle the page change here too, since we won't call edit_html() - activityReports[tabId] = await createReport({url: fullUrl, tabId}); - // Go on without parsing the page: it was explicitly blacklisted - let reason = blacklistedSite - ? `All ${blacklistedSite} blacklisted by user` - : "Address blacklisted by user"; - await addReportEntry(tabId, url, {"blacklisted": [blacklistedSite || url, reason], url: fullUrl}); - } - // use CSP to restrict JavaScript execution in the page - request.responseHeaders.unshift({ - name: `Content-security-policy`, - value: `script-src 'none';` - }); - return {responseHeaders: request.responseHeaders}; // let's skip the inline script parsing, since we block by CSP - } else { - let whitelistedSite = ListManager.siteMatch(site, whitelist); - let whitelisted = response.whitelisted = whitelistedSite || whitelist.contains(url); - if (type === "script") { - if (whitelisted) { - // accept the script and stop processing - addReportEntry(tabId, url, {url: topUrl, - "whitelisted": [url, whitelistedSite ? `User whitelisted ${whitelistedSite}` : "Whitelisted by user"]}); - return ResponseProcessor.ACCEPT; - } else { - let scriptInfo = await ExternalLicenses.check({url: fullUrl, tabId, frameId, documentUrl}); - if (scriptInfo) { - let verdict, ret; - let msg = scriptInfo.toString(); - if (scriptInfo.free) { - verdict = "accepted"; - ret = ResponseProcessor.ACCEPT; - } else { - verdict = "blocked"; - ret = ResponseProcessor.REJECT; - } - addReportEntry(tabId, url, {url, [verdict]: [url, msg]}); - return ret; - } - } - } - } - // it's a page (it's too early to report) or an unknown script: - // let's keep processing - return ResponseProcessor.CONTINUE; - }, - - /** - * Here we do the heavylifting, analyzing unknown scripts - */ - async post(response) { - let {type} = response.request; - let handle_it = type === "script" ? handle_script : handle_html; - return await handle_it(response, response.whitelisted); - } + /** + * Enforce white/black lists for url/site early (hashes will be handled later) + */ + async pre(response) { + let { request } = response; + let { url, type, tabId, frameId, documentUrl } = request; + + let fullUrl = url; + url = ListStore.urlItem(url); + let site = ListStore.siteItem(url); + + let blacklistedSite = ListManager.siteMatch(site, blacklist); + let blacklisted = blacklistedSite || blacklist.contains(url); + let topUrl = type === 'sub_frame' && request.frameAncestors && request.frameAncestors.pop() || documentUrl; + + if (blacklisted) { + if (type === 'script') { + // this shouldn't happen, because we intercept earlier in blockBlacklistedScripts() + return ResponseProcessor.REJECT; + } + if (type === 'main_frame') { // we handle the page change here too, since we won't call edit_html() + activityReports[tabId] = await createReport({ url: fullUrl, tabId }); + // Go on without parsing the page: it was explicitly blacklisted + let reason = blacklistedSite + ? `All ${blacklistedSite} blacklisted by user` + : 'Address blacklisted by user'; + await addReportEntry(tabId, { 'blacklisted': [blacklistedSite || url, reason], url: fullUrl }); + } + // use CSP to restrict JavaScript execution in the page + request.responseHeaders.unshift({ + name: 'Content-security-policy', + value: 'script-src \'none\';' + }); + return { responseHeaders: request.responseHeaders }; // let's skip the inline script parsing, since we block by CSP + } else { + let whitelistedSite = ListManager.siteMatch(site, whitelist); + let whitelisted = response.whitelisted = whitelistedSite || whitelist.contains(url); + if (type === 'script') { + if (whitelisted) { + // accept the script and stop processing + addReportEntry(tabId, { + url: topUrl, + 'whitelisted': [url, whitelistedSite ? `User whitelisted ${whitelistedSite}` : 'Whitelisted by user'] + }); + return ResponseProcessor.ACCEPT; + } else { + let scriptInfo = await ExternalLicenses.check({ url: fullUrl, tabId, frameId, documentUrl }); + if (scriptInfo) { + let verdict, ret; + let msg = scriptInfo.toString(); + if (scriptInfo.free) { + verdict = 'accepted'; + ret = ResponseProcessor.ACCEPT; + } else { + verdict = 'blocked'; + ret = ResponseProcessor.REJECT; + } + addReportEntry(tabId, { url, [verdict]: [url, msg] }); + return ret; + } + } + } + } + // it's a page (it's too early to report) or an unknown script: + // let's keep processing + return ResponseProcessor.CONTINUE; + }, + + /** + * Here we do the heavylifting, analyzing unknown scripts + */ + async post(response) { + let { type } = response.request; + let handle_it = type === 'script' ? handle_script : handle_html; + return await handle_it(response, response.whitelisted); + } } /** * Here we handle external script requests */ -async function handle_script(response, whitelisted){ - let {text, request} = response; - let {url, tabId, frameId} = request; - url = ListStore.urlItem(url); +async function handle_script(response, whitelisted) { + let { text, request } = response; + let { url, tabId } = request; + url = ListStore.urlItem(url); let edited = await get_script(text, url, tabId, whitelisted, -2); - return Array.isArray(edited) ? edited[0] : edited; + return Array.isArray(edited) ? edited[0] : edited; } /** @@ -3110,22 +2937,22 @@ async function handle_script(response, whitelisted){ * the DOCTYPE declaration */ function doc2HTML(doc) { - let s = doc.documentElement.outerHTML; - if (doc.doctype) { - let dt = doc.doctype; - let sDoctype = `\n${s}`; - } - return s; + let s = doc.documentElement.outerHTML; + if (doc.doctype) { + let dt = doc.doctype; + let sDoctype = `\n${s}`; + } + return s; } /** * Shortcut to create a correctly namespaced DOM HTML elements */ function createHTMLElement(doc, name) { - return doc.createElementNS("http://www.w3.org/1999/xhtml", name); + return doc.createElementNS('http://www.w3.org/1999/xhtml', name); } /** @@ -3133,10 +2960,10 @@ function createHTMLElement(doc, name) { * NOSCRIPT elements to visible the same way as NoScript and uBlock do) */ function forceElement(doc, element) { - let replacement = createHTMLElement(doc, "span"); - replacement.innerHTML = element.innerHTML; - element.replaceWith(replacement); - return replacement; + let replacement = createHTMLElement(doc, 'span'); + replacement.innerHTML = element.innerHTML; + element.replaceWith(replacement); + return replacement; } /** @@ -3145,1715 +2972,341 @@ function forceElement(doc, element) { * they have the "data-librejs-nodisplay" attribute). */ function forceNoscriptElements(doc) { - let shown = 0; - // inspired by NoScript's onScriptDisabled.js - for (let noscript of doc.querySelectorAll("noscript:not([data-librejs-nodisplay])")) { + let shown = 0; + // inspired by NoScript's onScriptDisabled.js + for (let noscript of doc.querySelectorAll('noscript:not([data-librejs-nodisplay])')) { let replacement = forceElement(doc, noscript); // emulate meta-refresh let meta = replacement.querySelector('meta[http-equiv="refresh"]'); if (meta) { - refresh = true; doc.head.appendChild(meta); } - shown++; + shown++; } - return shown; + return shown; } /** * Forces displaying any element having the "data-librejs-display" attribute and *