diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..0976b58e --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,32 @@ +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '22 17 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/Gruntfile.js b/Gruntfile.js index 0477fb92..224c9211 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -174,7 +174,7 @@ module.exports = function (grunt) { // previous one fails. & would coninue on a fail .join("&&") // Windows does not support \n properly - .replace("\n", "\\n"); + .replace(/\n/g, "\\n"); } grunt.initConfig({ diff --git a/src/core/ChefWorker.js b/src/core/ChefWorker.js index b0ba31a0..cac6a452 100644 --- a/src/core/ChefWorker.js +++ b/src/core/ChefWorker.js @@ -212,7 +212,7 @@ self.loadRequiredModules = function(recipeConfig) { if (!(module in OpModules)) { log.info(`Loading ${module} module`); self.sendStatusMessage(`Loading ${module} module`); - self.importScripts(`${self.docURL}/modules/${module}.js`); + self.importScripts(`${self.docURL}/modules/${module}.js`); // lgtm [js/client-side-unvalidated-url-redirection] self.sendStatusMessage(""); } }); diff --git a/src/core/Dish.mjs b/src/core/Dish.mjs index 1d592cbd..1afdef01 100755 --- a/src/core/Dish.mjs +++ b/src/core/Dish.mjs @@ -207,7 +207,7 @@ class Dish { const data = new Uint8Array(this.value.slice(0, 2048)), types = detectFileType(data); - if (!types.length || !types[0].mime || !types[0].mime === "text/plain") { + if (!types.length || !types[0].mime || !(types[0].mime === "text/plain")) { return null; } else { return types[0].mime; diff --git a/src/core/Utils.mjs b/src/core/Utils.mjs index bd3908d2..9c687ee4 100755 --- a/src/core/Utils.mjs +++ b/src/core/Utils.mjs @@ -705,7 +705,7 @@ class Utils { */ static stripHtmlTags(htmlStr, removeScriptAndStyle=false) { if (removeScriptAndStyle) { - htmlStr = htmlStr.replace(/<(script|style)[^>]*>.*<\/(script|style)>/gmi, ""); + htmlStr = htmlStr.replace(/<(script|style)[^>]*>.*?<\/(script|style)>/gi, ""); } return htmlStr.replace(/<[^>]+>/g, ""); } @@ -729,11 +729,10 @@ class Utils { ">": ">", '"': """, "'": "'", // ' not recommended because it's not in the HTML spec - "/": "/", // forward slash is included as it helps end an HTML entity "`": "`" }; - return str.replace(/[&<>"'/`]/g, function (match) { + return str.replace(/[&<>"'`]/g, function (match) { return HTML_CHARS[match]; }); } @@ -879,7 +878,7 @@ class Utils { while ((m = recipeRegex.exec(recipe))) { // Translate strings in args back to double-quotes args = m[2] - .replace(/"/g, '\\"') // Escape double quotes + .replace(/"/g, '\\"') // Escape double quotes lgtm [js/incomplete-sanitization] .replace(/(^|,|{|:)'/g, '$1"') // Replace opening ' with " .replace(/([^\\]|(?:\\\\)+)'(,|:|}|$)/g, '$1"$2') // Replace closing ' with " .replace(/\\'/g, "'"); // Unescape single quotes diff --git a/src/core/config/scripts/newOperation.mjs b/src/core/config/scripts/newOperation.mjs index 809f3558..fddeff97 100644 --- a/src/core/config/scripts/newOperation.mjs +++ b/src/core/config/scripts/newOperation.mjs @@ -121,7 +121,7 @@ prompt.get(schema, (err, result) => { const moduleName = result.opName.replace(/\w\S*/g, txt => { return txt.charAt(0).toUpperCase() + txt.substr(1); - }).replace(/[\s-()/./]/g, ""); + }).replace(/[\s-()./]/g, ""); const template = `/** diff --git a/src/core/lib/Base85.mjs b/src/core/lib/Base85.mjs index 8da729e2..83dcbd2f 100644 --- a/src/core/lib/Base85.mjs +++ b/src/core/lib/Base85.mjs @@ -32,9 +32,9 @@ export const ALPHABET_OPTIONS = [ * @returns {string} */ export function alphabetName(alphabet) { - alphabet = alphabet.replace("'", "'"); - alphabet = alphabet.replace("\"", """); - alphabet = alphabet.replace("\\", "\"); + alphabet = alphabet.replace(/'/g, "'"); + alphabet = alphabet.replace(/"/g, """); + alphabet = alphabet.replace(/\\/g, "\"); let name; ALPHABET_OPTIONS.forEach(function(a) { diff --git a/src/core/lib/Charts.mjs b/src/core/lib/Charts.mjs index 6685ee6e..93bf32f6 100644 --- a/src/core/lib/Charts.mjs +++ b/src/core/lib/Charts.mjs @@ -86,8 +86,8 @@ export function getScatterValues(input, recordDelimiter, fieldDelimiter, columnH } values = values.map(row => { - const x = parseFloat(row[0], 10), - y = parseFloat(row[1], 10); + const x = parseFloat(row[0]), + y = parseFloat(row[1]); if (Number.isNaN(x)) throw new OperationError("Values must be numbers in base 10."); if (Number.isNaN(y)) throw new OperationError("Values must be numbers in base 10."); @@ -121,8 +121,8 @@ export function getScatterValuesWithColour(input, recordDelimiter, fieldDelimite } values = values.map(row => { - const x = parseFloat(row[0], 10), - y = parseFloat(row[1], 10), + const x = parseFloat(row[0]), + y = parseFloat(row[1]), colour = row[2]; if (Number.isNaN(x)) throw new OperationError("Values must be numbers in base 10."); @@ -157,7 +157,7 @@ export function getSeriesValues(input, recordDelimiter, fieldDelimiter, columnHe values.forEach(row => { const serie = row[0], xVal = row[1], - val = parseFloat(row[2], 10); + val = parseFloat(row[2]); if (Number.isNaN(val)) throw new OperationError("Values must be numbers in base 10."); diff --git a/src/core/lib/FileType.mjs b/src/core/lib/FileType.mjs index 291760d7..7a6a0a4e 100644 --- a/src/core/lib/FileType.mjs +++ b/src/core/lib/FileType.mjs @@ -213,7 +213,7 @@ function locatePotentialSig(buf, sig, offset) { export function isType(type, buf) { const types = detectFileType(buf); - if (!(types && types.length)) return false; + if (!types.length) return false; if (typeof type === "string") { return types.reduce((acc, t) => { diff --git a/src/core/lib/Stream.mjs b/src/core/lib/Stream.mjs index a2edb462..f332f908 100644 --- a/src/core/lib/Stream.mjs +++ b/src/core/lib/Stream.mjs @@ -177,7 +177,7 @@ export default class Stream { // Get the skip table. const skiptable = preprocess(val, length); - let found = true; + let found; while (this.position < this.length) { // Until we hit the final element of val in the stream. diff --git a/src/core/operations/ExtractEmailAddresses.mjs b/src/core/operations/ExtractEmailAddresses.mjs index 13bc023b..43bf3b64 100644 --- a/src/core/operations/ExtractEmailAddresses.mjs +++ b/src/core/operations/ExtractEmailAddresses.mjs @@ -39,8 +39,8 @@ class ExtractEmailAddresses extends Operation { */ run(input, args) { const displayTotal = args[0], - // email regex from: https://www.regextester.com/98066 - regex = /(?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9])?\.)+[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/ig; + // email regex from: https://www.regextester.com/98066 + regex = /(?:[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9])?\.)+[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}\])/ig; return search(input, regex, null, displayTotal); } diff --git a/src/core/operations/FromBCD.mjs b/src/core/operations/FromBCD.mjs index 2fbc679f..e58116d3 100644 --- a/src/core/operations/FromBCD.mjs +++ b/src/core/operations/FromBCD.mjs @@ -95,7 +95,7 @@ class FromBCD extends Operation { if (!packed) { // Discard each high nibble for (let i = 0; i < nibbles.length; i++) { - nibbles.splice(i, 1); + nibbles.splice(i, 1); // lgtm [js/loop-iteration-skipped-due-to-shifting] } } diff --git a/src/core/operations/FromBase.mjs b/src/core/operations/FromBase.mjs index f374bdd0..4abd5c44 100644 --- a/src/core/operations/FromBase.mjs +++ b/src/core/operations/FromBase.mjs @@ -46,7 +46,7 @@ class FromBase extends Operation { } const number = input.replace(/\s/g, "").split("."); - let result = new BigNumber(number[0], radix) || 0; + let result = new BigNumber(number[0], radix); if (number.length === 1) return result; diff --git a/src/core/operations/FromBase32.mjs b/src/core/operations/FromBase32.mjs index 2715fdc1..73added6 100644 --- a/src/core/operations/FromBase32.mjs +++ b/src/core/operations/FromBase32.mjs @@ -84,10 +84,10 @@ class FromBase32 extends Operation { chr5 = ((enc7 & 7) << 5) | enc8; output.push(chr1); - if (enc2 & 3 !== 0 || enc3 !== 32) output.push(chr2); - if (enc4 & 15 !== 0 || enc5 !== 32) output.push(chr3); - if (enc5 & 1 !== 0 || enc6 !== 32) output.push(chr4); - if (enc7 & 7 !== 0 || enc8 !== 32) output.push(chr5); + if ((enc2 & 3) !== 0 || enc3 !== 32) output.push(chr2); + if ((enc4 & 15) !== 0 || enc5 !== 32) output.push(chr3); + if ((enc5 & 1) !== 0 || enc6 !== 32) output.push(chr4); + if ((enc7 & 7) !== 0 || enc8 !== 32) output.push(chr5); } return output; diff --git a/src/core/operations/Lorenz.mjs b/src/core/operations/Lorenz.mjs index e723bbb5..a9c2029b 100644 --- a/src/core/operations/Lorenz.mjs +++ b/src/core/operations/Lorenz.mjs @@ -376,7 +376,7 @@ class Lorenz extends Operation { // Psi wheels only move sometimes, dependent on M37 current setting and limitations const basicmotor = m37lug; - let totalmotor = basicmotor; + let totalmotor; let lim = 0; p5[2] = p5[1]; diff --git a/src/core/operations/OpticalCharacterRecognition.mjs b/src/core/operations/OpticalCharacterRecognition.mjs index 6a3c3f10..305c5ccd 100644 --- a/src/core/operations/OpticalCharacterRecognition.mjs +++ b/src/core/operations/OpticalCharacterRecognition.mjs @@ -51,7 +51,7 @@ class OpticalCharacterRecognition extends Operation { async run(input, args) { const [showConfidence] = args; - if (!isWorkerEnvironment()) throw OperationError("This operation only works in a browser"); + if (!isWorkerEnvironment()) throw new OperationError("This operation only works in a browser"); const type = isImage(input); if (!type) { diff --git a/src/core/operations/PHPDeserialize.mjs b/src/core/operations/PHPDeserialize.mjs index 2c510b35..77d18bc2 100644 --- a/src/core/operations/PHPDeserialize.mjs +++ b/src/core/operations/PHPDeserialize.mjs @@ -111,7 +111,7 @@ class PHPDeserialize extends Operation { } else { const numberCheck = lastItem.match(/[0-9]+/); if (args[0] && numberCheck && numberCheck[0].length === lastItem.length) { - result.push("\"" + lastItem + "\": " + item); + result.push('"' + lastItem + '": ' + item); } else { result.push(lastItem + ": " + item); } @@ -149,11 +149,11 @@ class PHPDeserialize extends Operation { const length = readUntil(":"); expect("\""); const value = read(length); - expect("\";"); + expect('";'); if (args[0]) { - return "\"" + value.replace(/"/g, "\\\"") + "\""; + return '"' + value.replace(/"/g, '\\"') + '"'; // lgtm [js/incomplete-sanitization] } else { - return "\"" + value + "\""; + return '"' + value + '"'; } } diff --git a/src/core/operations/ParseIPv6Address.mjs b/src/core/operations/ParseIPv6Address.mjs index 78df0b19..d3480e32 100644 --- a/src/core/operations/ParseIPv6Address.mjs +++ b/src/core/operations/ParseIPv6Address.mjs @@ -169,7 +169,7 @@ class ParseIPv6Address extends Operation { // Detect possible EUI-64 addresses - if ((ipv6[5] & 0xff === 0xff) && (ipv6[6] >>> 8 === 0xfe)) { + if (((ipv6[5] & 0xff) === 0xff) && (ipv6[6] >>> 8 === 0xfe)) { output += "\n\nThis IPv6 address contains a modified EUI-64 address, identified by the presence of FF:FE in the 12th and 13th octets."; const intIdent = Utils.hex(ipv6[4] >>> 8) + ":" + Utils.hex(ipv6[4] & 0xff) + ":" + diff --git a/src/core/operations/ParseSSHHostKey.mjs b/src/core/operations/ParseSSHHostKey.mjs index 6472b287..8a3bf5da 100644 --- a/src/core/operations/ParseSSHHostKey.mjs +++ b/src/core/operations/ParseSSHHostKey.mjs @@ -87,7 +87,7 @@ class ParseSSHHostKey extends Operation { * @returns {byteArray} */ convertKeyToBinary(inputKey, inputFormat) { - const keyPattern = new RegExp(/^(?:[ssh]|[ecdsa-sha2])\S+\s+(\S*)/), + const keyPattern = new RegExp(/^(?:ssh|ecdsa-sha2)\S+\s+(\S*)/), keyMatch = inputKey.match(keyPattern); if (keyMatch) { diff --git a/src/core/operations/RegularExpression.mjs b/src/core/operations/RegularExpression.mjs index 9e627ad9..8771b55f 100644 --- a/src/core/operations/RegularExpression.mjs +++ b/src/core/operations/RegularExpression.mjs @@ -45,7 +45,7 @@ class RegularExpression extends Operation { }, { name: "Email address", - value: "(?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9])?\\.)+[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\\])" + value: "(?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9](?:[\\u00A0-\\uD7FF\\uE000-\\uFFFF-a-z0-9-]*[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9])?\\.)+[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9](?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9-]*[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}\\])" }, { name: "URL", diff --git a/src/core/operations/SharpenImage.mjs b/src/core/operations/SharpenImage.mjs index 3306a49b..3882b7aa 100644 --- a/src/core/operations/SharpenImage.mjs +++ b/src/core/operations/SharpenImage.mjs @@ -81,7 +81,7 @@ class SharpenImage extends Operation { if (isWorkerEnvironment()) self.sendStatusMessage("Sharpening image... (Blurring cloned image)"); - const blurImage = gaussianBlur(image.clone(), radius, 3); + const blurImage = gaussianBlur(image.clone(), radius); if (isWorkerEnvironment()) diff --git a/src/core/operations/Sort.mjs b/src/core/operations/Sort.mjs index 84bce4c9..a1148f7c 100644 --- a/src/core/operations/Sort.mjs +++ b/src/core/operations/Sort.mjs @@ -125,7 +125,7 @@ class Sort extends Operation { const ret = a_[i].localeCompare(b_[i]); // Compare strings if (ret !== 0) return ret; } - if (!isNaN(a_[i]) && !isNaN(a_[i])) { // Compare numbers + if (!isNaN(a_[i]) && !isNaN(b_[i])) { // Compare numbers if (a_[i] - b_[i] !== 0) return a_[i] - b_[i]; } } @@ -163,7 +163,7 @@ class Sort extends Operation { const ret = a_[i].localeCompare(b_[i]); // Compare strings if (ret !== 0) return ret; } - if (!isNaN(a_[i]) && !isNaN(a_[i])) { // Compare numbers + if (!isNaN(a_[i]) && !isNaN(b_[i])) { // Compare numbers if (a_[i] - b_[i] !== 0) return a_[i] - b_[i]; } } diff --git a/src/core/operations/ToCharcode.mjs b/src/core/operations/ToCharcode.mjs index 5ad287e4..a4806115 100644 --- a/src/core/operations/ToCharcode.mjs +++ b/src/core/operations/ToCharcode.mjs @@ -52,7 +52,7 @@ class ToCharcode extends Operation { const delim = Utils.charRep(args[0] || "Space"), base = args[1]; let output = "", - padding = 2, + padding, ordinal; if (base < 2 || base > 36) { diff --git a/src/core/operations/UnescapeUnicodeCharacters.mjs b/src/core/operations/UnescapeUnicodeCharacters.mjs index c639613e..5bb0e5ac 100644 --- a/src/core/operations/UnescapeUnicodeCharacters.mjs +++ b/src/core/operations/UnescapeUnicodeCharacters.mjs @@ -47,7 +47,6 @@ class UnescapeUnicodeCharacters extends Operation { while ((m = regex.exec(input))) { // Add up to match output += input.slice(i, m.index); - i = m.index; // Add match output += Utils.chr(parseInt(m[1], 16)); diff --git a/src/web/HTMLIngredient.mjs b/src/web/HTMLIngredient.mjs index 18503dff..2c638405 100755 --- a/src/web/HTMLIngredient.mjs +++ b/src/web/HTMLIngredient.mjs @@ -153,7 +153,7 @@ class HTMLIngredient { for (i = 0; i < this.value.length; i++) { if ((m = this.value[i].match(/\[([a-z0-9 -()^]+)\]/i))) { html += ``; - } else if ((m = this.value[i].match(/\[\/([a-z0-9 -()^]+)\]/i))) { + } else if (this.value[i].match(/\[\/([a-z0-9 -()^]+)\]/i)) { html += ""; } else { html += ``; @@ -177,7 +177,7 @@ class HTMLIngredient { for (i = 0; i < this.value.length; i++) { if ((m = this.value[i].name.match(/\[([a-z0-9 -()^]+)\]/i))) { html += ``; - } else if ((m = this.value[i].name.match(/\[\/([a-z0-9 -()^]+)\]/i))) { + } else if (this.value[i].name.match(/\[\/([a-z0-9 -()^]+)\]/i)) { html += ""; } else { const val = this.type === "populateMultiOption" ? diff --git a/src/web/HTMLOperation.mjs b/src/web/HTMLOperation.mjs index 5fcd7b98..df5de5a8 100755 --- a/src/web/HTMLOperation.mjs +++ b/src/web/HTMLOperation.mjs @@ -5,6 +5,7 @@ */ import HTMLIngredient from "./HTMLIngredient.mjs"; +import Utils from "../core/Utils.mjs"; /** @@ -72,7 +73,7 @@ class HTMLOperation { * @returns {string} */ toFullHtml() { - let html = `
${this.name}
+ let html = `
${Utils.escapeHtml(this.name)}
`; for (let i = 0; i < this.ingList.length; i++) { @@ -151,15 +152,16 @@ class HTMLOperation { */ function titleFromWikiLink(url) { const splitURL = url.split("/"); - if (splitURL.indexOf("wikipedia.org") < 0 && splitURL.indexOf("forensicswiki.org") < 0) { + if (!splitURL.includes("wikipedia.org") && !splitURL.includes("forensicswiki.xyz")) { // Not a wiki link, return full URL return `More Informationopen_in_new`; } - const wikiName = splitURL.indexOf("forensicswiki.org") < 0 ? "Wikipedia" : "Forensics Wiki"; + const wikiName = splitURL.includes("forensicswiki.xyz") ? "Forensics Wiki" : "Wikipedia"; const pageTitle = decodeURIComponent(splitURL[splitURL.length - 1]) - .replace(/_/g, " "); + .replace(/_/g, " ") + .replace(/index\.php\?title=/g, ""); return `${pageTitle}open_in_new on ${wikiName}`; } diff --git a/src/web/html/index.html b/src/web/html/index.html index 121f0780..efdd8046 100755 --- a/src/web/html/index.html +++ b/src/web/html/index.html @@ -153,7 +153,7 @@ diff --git a/src/web/waiters/ControlsWaiter.mjs b/src/web/waiters/ControlsWaiter.mjs index 2f2705aa..f252dfcd 100755 --- a/src/web/waiters/ControlsWaiter.mjs +++ b/src/web/waiters/ControlsWaiter.mjs @@ -102,7 +102,7 @@ class ControlsWaiter { const saveLinkEl = document.getElementById("save-link"); const saveLink = this.generateStateUrl(includeRecipe, includeInput, recipeConfig); - saveLinkEl.innerHTML = Utils.truncate(saveLink, 120); + saveLinkEl.innerHTML = Utils.escapeHtml(Utils.truncate(saveLink, 120)); saveLinkEl.setAttribute("href", saveLink); } @@ -138,7 +138,7 @@ class ControlsWaiter { const params = [ includeRecipe ? ["recipe", recipeStr] : undefined, - includeInput ? ["input", input] : undefined, + includeInput ? ["input", Utils.escapeHtml(input)] : undefined, ]; const hash = params diff --git a/src/web/waiters/InputWaiter.mjs b/src/web/waiters/InputWaiter.mjs index df439780..b421d8d8 100644 --- a/src/web/waiters/InputWaiter.mjs +++ b/src/web/waiters/InputWaiter.mjs @@ -510,10 +510,6 @@ class InputWaiter { if (inputNum !== activeTab) return; const fileLoaded = document.getElementById("input-file-loaded"); - let oldProgress = fileLoaded.textContent; - if (oldProgress !== "Error") { - oldProgress = parseInt(oldProgress.replace("%", ""), 10); - } if (progress === "error") { fileLoaded.textContent = "Error"; fileLoaded.style.color = "#FF0000"; @@ -1276,7 +1272,7 @@ class InputWaiter { const func = function(time) { if (this.mousedown) { this.changeTabRight(); - const newTime = (time > 50) ? time = time - 10 : 50; + const newTime = (time > 50) ? time - 10 : 50; setTimeout(func.bind(this, [newTime]), newTime); } }; @@ -1293,7 +1289,7 @@ class InputWaiter { const func = function(time) { if (this.mousedown) { this.changeTabLeft(); - const newTime = (time > 50) ? time = time - 10 : 50; + const newTime = (time > 50) ? time - 10 : 50; setTimeout(func.bind(this, [newTime]), newTime); } }; diff --git a/src/web/waiters/OperationsWaiter.mjs b/src/web/waiters/OperationsWaiter.mjs index 8947b038..200ae5df 100755 --- a/src/web/waiters/OperationsWaiter.mjs +++ b/src/web/waiters/OperationsWaiter.mjs @@ -121,7 +121,7 @@ class OperationsWaiter { if (nameMatch || descPos >= 0) { const operation = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager); if (highlight) { - operation.highlightSearchStrings(calcMatchRanges(idxs) || [], [[descPos, inStr.length]]); + operation.highlightSearchStrings(calcMatchRanges(idxs), [[descPos, inStr.length]]); } if (nameMatch) { diff --git a/src/web/waiters/OutputWaiter.mjs b/src/web/waiters/OutputWaiter.mjs index 0ba0bbf6..f5aaaabd 100755 --- a/src/web/waiters/OutputWaiter.mjs +++ b/src/web/waiters/OutputWaiter.mjs @@ -306,8 +306,6 @@ class OutputWaiter { outputText.value = ""; outputHtml.innerHTML = ""; - lines = 0; - length = 0; this.toggleLoader(false); return; } @@ -765,7 +763,7 @@ class OutputWaiter { const func = function(time) { if (this.mousedown) { this.changeTabRight(); - const newTime = (time > 50) ? time = time - 10 : 50; + const newTime = (time > 50) ? time - 10 : 50; setTimeout(func.bind(this, [newTime]), newTime); } }; @@ -782,7 +780,7 @@ class OutputWaiter { const func = function(time) { if (this.mousedown) { this.changeTabLeft(); - const newTime = (time > 50) ? time = time - 10 : 50; + const newTime = (time > 50) ? time - 10 : 50; setTimeout(func.bind(this, [newTime]), newTime); } }; diff --git a/src/web/waiters/RecipeWaiter.mjs b/src/web/waiters/RecipeWaiter.mjs index ba0e7b11..f4107e66 100755 --- a/src/web/waiters/RecipeWaiter.mjs +++ b/src/web/waiters/RecipeWaiter.mjs @@ -316,7 +316,7 @@ class RecipeWaiter { }; } else if (ingList[j].getAttribute("type") === "number") { // number - ingredients[j] = parseFloat(ingList[j].value, 10); + ingredients[j] = parseFloat(ingList[j].value); } else { // all others ingredients[j] = ingList[j].value;