This commit is contained in:
Thomas Grainger 2017-05-17 14:45:59 +00:00 committed by GitHub
commit b77cdeafe1
42 changed files with 496 additions and 493 deletions

View file

@ -1 +1,2 @@
src/core/lib/** src/core/lib/**
build

View file

@ -85,7 +85,9 @@
"no-whitespace-before-property": "error", "no-whitespace-before-property": "error",
"operator-linebreak": ["error", "after"], "operator-linebreak": ["error", "after"],
"space-in-parens": "error", "space-in-parens": "error",
"no-var": "error" "no-var": "error",
"prefer-template": "error",
"template-curly-spacing": ["error", "never"]
}, },
"globals": { "globals": {
"$": false, "$": false,

View file

@ -54,7 +54,7 @@ module.exports = function (grunt) {
// Project configuration // Project configuration
const compileTime = grunt.template.today("dd/mm/yyyy HH:MM:ss") + " UTC", const compileTime = `${grunt.template.today("dd/mm/yyyy HH:MM:ss")} UTC`,
banner = "/**\n" + banner = "/**\n" +
"* CyberChef - The Cyber Swiss Army Knife\n" + "* CyberChef - The Cyber Swiss Army Knife\n" +
"*\n" + "*\n" +
@ -229,7 +229,7 @@ module.exports = function (grunt) {
entry: "./src/web/index.js", entry: "./src/web/index.js",
output: { output: {
filename: "scripts.js", filename: "scripts.js",
path: __dirname + "/build/dev" path: `${__dirname}/build/dev`
}, },
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
@ -245,7 +245,7 @@ module.exports = function (grunt) {
entry: "./src/web/index.js", entry: "./src/web/index.js",
output: { output: {
filename: "scripts.js", filename: "scripts.js",
path: __dirname + "/build/prod" path: `${__dirname}/build/prod`
}, },
plugins: [ plugins: [
new webpack.optimize.UglifyJsPlugin({ new webpack.optimize.UglifyJsPlugin({
@ -287,7 +287,7 @@ module.exports = function (grunt) {
entry: "./test/index.js", entry: "./test/index.js",
output: { output: {
filename: "index.js", filename: "index.js",
path: __dirname + "/build/test" path: `${__dirname}/build/test`
} }
}, },
node: { node: {
@ -295,7 +295,7 @@ module.exports = function (grunt) {
entry: "./src/node/index.js", entry: "./src/node/index.js",
output: { output: {
filename: "CyberChef.js", filename: "CyberChef.js",
path: __dirname + "/build/node", path: `${__dirname}/build/node`,
library: "CyberChef", library: "CyberChef",
libraryTarget: "commonjs2" libraryTarget: "commonjs2"
} }
@ -307,7 +307,7 @@ module.exports = function (grunt) {
process: function (content) { process: function (content) {
// Add Google Analytics code to index.html // Add Google Analytics code to index.html
content = content.replace("</body></html>", content = content.replace("</body></html>",
grunt.file.read("src/web/static/ga.html") + "</body></html>"); `${grunt.file.read("src/web/static/ga.html")}</body></html>`);
return grunt.template.process(content); return grunt.template.process(content);
} }
}, },

View file

@ -105,7 +105,7 @@ Dish.prototype.set = function(value, type) {
if (!this.valid()) { if (!this.valid()) {
const sample = Utils.truncate(JSON.stringify(this.value), 13); const sample = Utils.truncate(JSON.stringify(this.value), 13);
throw "Data is not a valid " + Dish.enumLookup(type) + ": " + sample; throw `Data is not a valid ${Dish.enumLookup(type)}: ${sample}`;
} }
}; };

View file

@ -81,7 +81,7 @@ Ingredient.prepare = function(data, type) {
number = parseFloat(data); number = parseFloat(data);
if (isNaN(number)) { if (isNaN(number)) {
const sample = Utils.truncate(data.toString(), 10); const sample = Utils.truncate(data.toString(), 10);
throw "Invalid ingredient value. Not a number: " + sample; throw `Invalid ingredient value. Not a number: ${sample}`;
} }
return number; return number;
default: default:

View file

@ -182,11 +182,11 @@ Recipe.prototype.execute = async function(dish, startFrom) {
e.progress = i; e.progress = i;
if (e.fileName) { if (e.fileName) {
e.displayStr = op.name + " - " + e.name + " in " + e.displayStr = `${op.name} - ${e.name} in ${
e.fileName + " on line " + e.lineNumber + e.fileName} on line ${e.lineNumber
".<br><br>Message: " + (e.displayStr || e.message); }.<br><br>Message: ${e.displayStr || e.message}`;
} else { } else {
e.displayStr = op.name + " - " + (e.displayStr || e.message); e.displayStr = `${op.name} - ${e.displayStr || e.message}`;
} }
throw e; throw e;

View file

@ -240,7 +240,7 @@ const Utils = {
*/ */
parseEscapedChars: function(str) { parseEscapedChars: function(str) {
return str.replace(/(\\)?\\([nrtbf]|x[\da-f]{2})/g, function(m, a, b) { return str.replace(/(\\)?\\([nrtbf]|x[\da-f]{2})/g, function(m, a, b) {
if (a === "\\") return "\\"+b; if (a === "\\") return `\\${b}`;
switch (b[0]) { switch (b[0]) {
case "n": case "n":
return "\n"; return "\n";
@ -338,7 +338,7 @@ const Utils = {
if (!byteArray) return ""; if (!byteArray) return "";
let hexStr = ""; let hexStr = "";
for (let i = 0; i < byteArray.length; i++) { for (let i = 0; i < byteArray.length; i++) {
hexStr += Utils.hex(byteArray[i]) + " "; hexStr += `${Utils.hex(byteArray[i])} `;
} }
return hexStr.slice(0, hexStr.length-1); return hexStr.slice(0, hexStr.length-1);
}, },
@ -587,7 +587,7 @@ const Utils = {
for (let i = 0; i < unicStr.length; i++) { for (let i = 0; i < unicStr.length; i++) {
const ord = unicStr.charCodeAt(i); const ord = unicStr.charCodeAt(i);
if (!(ord in Utils.UNIC_WIN1251_MAP)) if (!(ord in Utils.UNIC_WIN1251_MAP))
throw "Character '" + unicStr.charAt(i) + "' isn't supported by Windows-1251"; throw `Character '${unicStr.charAt(i)}' isn't supported by Windows-1251`;
res.push(String.fromCharCode(Utils.UNIC_WIN1251_MAP[ord])); res.push(String.fromCharCode(Utils.UNIC_WIN1251_MAP[ord]));
} }
@ -611,7 +611,7 @@ const Utils = {
for (let i = 0; i < win1251Str.length; i++) { for (let i = 0; i < win1251Str.length; i++) {
const ord = win1251Str.charCodeAt(i); const ord = win1251Str.charCodeAt(i);
if (!(ord in Utils.WIN1251_UNIC_MAP)) if (!(ord in Utils.WIN1251_UNIC_MAP))
throw "Character '" + win1251Str.charAt(i) + "' isn't supported by Windows-1251"; throw `Character '${win1251Str.charAt(i)}' isn't supported by Windows-1251`;
res.push(String.fromCharCode(Utils.WIN1251_UNIC_MAP[ord])); res.push(String.fromCharCode(Utils.WIN1251_UNIC_MAP[ord]));
} }
@ -706,7 +706,7 @@ const Utils = {
i = 0; i = 0;
if (removeNonAlphChars) { if (removeNonAlphChars) {
const re = new RegExp("[^" + alphabet.replace(/[\[\]\\\-^$]/g, "\\$&") + "]", "g"); const re = new RegExp(`[^${alphabet.replace(/[\[\]\\\-^$]/g, "\\$&")}]`, "g");
data = data.replace(re, ""); data = data.replace(re, "");
} }
@ -765,8 +765,8 @@ const Utils = {
} }
// Add \x or 0x to beginning // Add \x or 0x to beginning
if (delim === "0x") output = "0x" + output; if (delim === "0x") output = `0x${output}`;
if (delim === "\\x") output = "\\x" + output; if (delim === "\\x") output = `\\x${output}`;
if (delim.length) if (delim.length)
return output.slice(0, -delim.length); return output.slice(0, -delim.length);
@ -1017,12 +1017,12 @@ const Utils = {
*/ */
displayFilesAsHTML: function(files){ displayFilesAsHTML: function(files){
const formatDirectory = function(file) { const formatDirectory = function(file) {
const html = "<div class='panel panel-default'>" + const html = `${"<div class='panel panel-default'>" +
"<div class='panel-heading' role='tab'>" + "<div class='panel-heading' role='tab'>" +
"<h4 class='panel-title'>" + "<h4 class='panel-title'>"}${
file.fileName + file.fileName
// The following line is for formatting when HTML is stripped // The following line is for formatting when HTML is stripped
"<span style='display: none'>\n0 bytes\n</span>" + }<span style='display: none'>\n0 bytes\n</span>` +
"</h4>" + "</h4>" +
"</div>" + "</div>" +
"</div>"; "</div>";
@ -1036,45 +1036,45 @@ const Utils = {
); );
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
const downloadAnchorElem = "<a href='" + blobUrl + "' " + const downloadAnchorElem = `<a href='${blobUrl}' ` +
"title='Download " + Utils.escapeHtml(file.fileName) + "' " + `title='Download ${Utils.escapeHtml(file.fileName)}' ` +
"download='" + Utils.escapeHtml(file.fileName) + "'>\u21B4</a>"; `download='${Utils.escapeHtml(file.fileName)}'>\u21B4</a>`;
const expandFileContentsElem = "<a href='#collapse" + i + "' " + const expandFileContentsElem = `<a href='#collapse${i}' ` +
"class='collapsed' " + "class='collapsed' " +
"data-toggle='collapse' " + "data-toggle='collapse' " +
"aria-expanded='true' " + "aria-expanded='true' " +
"aria-controls='collapse" + i + "' " + `aria-controls='collapse${i}' ` +
"title=\"Show/hide contents of '" + Utils.escapeHtml(file.fileName) + "'\">&#x1F50D</a>"; `title="Show/hide contents of '${Utils.escapeHtml(file.fileName)}'">&#x1F50D</a>`;
const html = "<div class='panel panel-default'>" + const html = `${"<div class='panel panel-default'>" +
"<div class='panel-heading' role='tab' id='heading" + i + "'>" + "<div class='panel-heading' role='tab' id='heading"}${i}'>` +
"<h4 class='panel-title'>" + "<h4 class='panel-title'>" +
"<div>" + `<div>${
Utils.escapeHtml(file.fileName) + Utils.escapeHtml(file.fileName)
" " + expandFileContentsElem + } ${expandFileContentsElem
" " + downloadAnchorElem + } ${downloadAnchorElem
"<span class='pull-right'>" + }<span class='pull-right'>` +
// These are for formatting when stripping HTML // These are for formatting when stripping HTML
"<span style='display: none'>\n</span>" + `<span style='display: none'>\n</span>${
file.size.toLocaleString() + " bytes" + file.size.toLocaleString()} bytes` +
"<span style='display: none'>\n</span>" + "<span style='display: none'>\n</span>" +
"</span>" + "</span>" +
"</div>" + "</div>" +
"</h4>" + "</h4>" +
"</div>" + "</div>" +
"<div id='collapse" + i + "' class='panel-collapse collapse' " + `<div id='collapse${i}' class='panel-collapse collapse' ` +
"role='tabpanel' aria-labelledby='heading" + i + "'>" + `role='tabpanel' aria-labelledby='heading${i}'>` +
"<div class='panel-body'>" + "<div class='panel-body'>" +
"<pre><code>" + Utils.escapeHtml(file.contents) + "</pre></code></div>" + `<pre><code>${Utils.escapeHtml(file.contents)}</pre></code></div>` +
"</div>" + "</div>" +
"</div>"; "</div>";
return html; return html;
}; };
let html = "<div style='padding: 5px;'>" + let html = `<div style='padding: 5px;'>${
files.length + files.length
" file(s) found</div>\n"; } file(s) found</div>\n`;
files.forEach(function(file, i) { files.forEach(function(file, i) {
if (typeof file.contents !== "undefined") { if (typeof file.contents !== "undefined") {
html += formatFile(file, i); html += formatFile(file, i);

View file

@ -109,7 +109,7 @@ const Base58 = {
if (removeNonAlphaChars) { if (removeNonAlphaChars) {
return; return;
} else { } else {
throw ("Char '" + c + "' at position " + charIndex + " not in alphabet"); throw (`Char '${c}' at position ${charIndex} not in alphabet`);
} }
} }

View file

@ -149,7 +149,7 @@ const Base64 = {
i = 0; i = 0;
if (removeNonAlphChars) { if (removeNonAlphChars) {
const re = new RegExp("[^" + alphabet.replace(/[\]\\\-^]/g, "\\$&") + "]", "g"); const re = new RegExp(`[^${alphabet.replace(/[\]\\\-^]/g, "\\$&")}]`, "g");
input = input.replace(re, ""); input = input.replace(re, "");
} }
@ -218,23 +218,23 @@ const Base64 = {
// Highlight offset 0 // Highlight offset 0
if (len0 % 4 === 2) { if (len0 % 4 === 2) {
staticSection = offset0.slice(0, -3); staticSection = offset0.slice(0, -3);
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" + offset0 = `<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet).slice(0, -2)) + "'>" + Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet).slice(0, -2))}'>${
staticSection + "</span>" + staticSection}</span>` +
"<span class='hlgreen'>" + offset0.substr(offset0.length - 3, 1) + "</span>" + `<span class='hlgreen'>${offset0.substr(offset0.length - 3, 1)}</span>` +
"<span class='hlred'>" + offset0.substr(offset0.length - 2) + "</span>"; `<span class='hlred'>${offset0.substr(offset0.length - 2)}</span>`;
} else if (len0 % 4 === 3) { } else if (len0 % 4 === 3) {
staticSection = offset0.slice(0, -2); staticSection = offset0.slice(0, -2);
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" + offset0 = `<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet).slice(0, -1)) + "'>" + Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet).slice(0, -1))}'>${
staticSection + "</span>" + staticSection}</span>` +
"<span class='hlgreen'>" + offset0.substr(offset0.length - 2, 1) + "</span>" + `<span class='hlgreen'>${offset0.substr(offset0.length - 2, 1)}</span>` +
"<span class='hlred'>" + offset0.substr(offset0.length - 1) + "</span>"; `<span class='hlred'>${offset0.substr(offset0.length - 1)}</span>`;
} else { } else {
staticSection = offset0; staticSection = offset0;
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" + offset0 = `<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet)) + "'>" + Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet))}'>${
staticSection + "</span>"; staticSection}</span>`;
} }
if (!showVariable) { if (!showVariable) {
@ -243,28 +243,28 @@ const Base64 = {
// Highlight offset 1 // Highlight offset 1
padding = "<span class='hlred'>" + offset1.substr(0, 1) + "</span>" + padding = `<span class='hlred'>${offset1.substr(0, 1)}</span>` +
"<span class='hlgreen'>" + offset1.substr(1, 1) + "</span>"; `<span class='hlgreen'>${offset1.substr(1, 1)}</span>`;
offset1 = offset1.substr(2); offset1 = offset1.substr(2);
if (len1 % 4 === 2) { if (len1 % 4 === 2) {
staticSection = offset1.slice(0, -3); staticSection = offset1.slice(0, -3);
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset1 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64("AA" + staticSection, alphabet).slice(1, -2)) + "'>" + Utils.escapeHtml(Utils.fromBase64(`AA${staticSection}`, alphabet).slice(1, -2))}'>${
staticSection + "</span>" + staticSection}</span>` +
"<span class='hlgreen'>" + offset1.substr(offset1.length - 3, 1) + "</span>" + `<span class='hlgreen'>${offset1.substr(offset1.length - 3, 1)}</span>` +
"<span class='hlred'>" + offset1.substr(offset1.length - 2) + "</span>"; `<span class='hlred'>${offset1.substr(offset1.length - 2)}</span>`;
} else if (len1 % 4 === 3) { } else if (len1 % 4 === 3) {
staticSection = offset1.slice(0, -2); staticSection = offset1.slice(0, -2);
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset1 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64("AA" + staticSection, alphabet).slice(1, -1)) + "'>" + Utils.escapeHtml(Utils.fromBase64(`AA${staticSection}`, alphabet).slice(1, -1))}'>${
staticSection + "</span>" + staticSection}</span>` +
"<span class='hlgreen'>" + offset1.substr(offset1.length - 2, 1) + "</span>" + `<span class='hlgreen'>${offset1.substr(offset1.length - 2, 1)}</span>` +
"<span class='hlred'>" + offset1.substr(offset1.length - 1) + "</span>"; `<span class='hlred'>${offset1.substr(offset1.length - 1)}</span>`;
} else { } else {
staticSection = offset1; staticSection = offset1;
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset1 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64("AA" + staticSection, alphabet).slice(1)) + "'>" + Utils.escapeHtml(Utils.fromBase64(`AA${staticSection}`, alphabet).slice(1))}'>${
staticSection + "</span>"; staticSection}</span>`;
} }
if (!showVariable) { if (!showVariable) {
@ -272,43 +272,43 @@ const Base64 = {
} }
// Highlight offset 2 // Highlight offset 2
padding = "<span class='hlred'>" + offset2.substr(0, 2) + "</span>" + padding = `<span class='hlred'>${offset2.substr(0, 2)}</span>` +
"<span class='hlgreen'>" + offset2.substr(2, 1) + "</span>"; `<span class='hlgreen'>${offset2.substr(2, 1)}</span>`;
offset2 = offset2.substr(3); offset2 = offset2.substr(3);
if (len2 % 4 === 2) { if (len2 % 4 === 2) {
staticSection = offset2.slice(0, -3); staticSection = offset2.slice(0, -3);
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset2 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64("AAA" + staticSection, alphabet).slice(2, -2)) + "'>" + Utils.escapeHtml(Utils.fromBase64(`AAA${staticSection}`, alphabet).slice(2, -2))}'>${
staticSection + "</span>" + staticSection}</span>` +
"<span class='hlgreen'>" + offset2.substr(offset2.length - 3, 1) + "</span>" + `<span class='hlgreen'>${offset2.substr(offset2.length - 3, 1)}</span>` +
"<span class='hlred'>" + offset2.substr(offset2.length - 2) + "</span>"; `<span class='hlred'>${offset2.substr(offset2.length - 2)}</span>`;
} else if (len2 % 4 === 3) { } else if (len2 % 4 === 3) {
staticSection = offset2.slice(0, -2); staticSection = offset2.slice(0, -2);
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset2 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64("AAA" + staticSection, alphabet).slice(2, -2)) + "'>" + Utils.escapeHtml(Utils.fromBase64(`AAA${staticSection}`, alphabet).slice(2, -2))}'>${
staticSection + "</span>" + staticSection}</span>` +
"<span class='hlgreen'>" + offset2.substr(offset2.length - 2, 1) + "</span>" + `<span class='hlgreen'>${offset2.substr(offset2.length - 2, 1)}</span>` +
"<span class='hlred'>" + offset2.substr(offset2.length - 1) + "</span>"; `<span class='hlred'>${offset2.substr(offset2.length - 1)}</span>`;
} else { } else {
staticSection = offset2; staticSection = offset2;
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" + offset2 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64("AAA" + staticSection, alphabet).slice(2)) + "'>" + Utils.escapeHtml(Utils.fromBase64(`AAA${staticSection}`, alphabet).slice(2))}'>${
staticSection + "</span>"; staticSection}</span>`;
} }
if (!showVariable) { if (!showVariable) {
offset2 = staticSection; offset2 = staticSection;
} }
return (showVariable ? "Characters highlighted in <span class='hlgreen'>green</span> could change if the input is surrounded by more data." + return (showVariable ? `${"Characters highlighted in <span class='hlgreen'>green</span> could change if the input is surrounded by more data." +
"\nCharacters highlighted in <span class='hlred'>red</span> are for padding purposes only." + "\nCharacters highlighted in <span class='hlred'>red</span> are for padding purposes only." +
"\nUnhighlighted characters are <span data-toggle='tooltip' data-placement='top' title='Tooltip on left'>static</span>." + "\nUnhighlighted characters are <span data-toggle='tooltip' data-placement='top' title='Tooltip on left'>static</span>." +
"\nHover over the static sections to see what they decode to on their own.\n" + "\nHover over the static sections to see what they decode to on their own.\n" +
"\nOffset 0: " + offset0 + "\nOffset 0: "}${offset0
"\nOffset 1: " + offset1 + }\nOffset 1: ${offset1
"\nOffset 2: " + offset2 + }\nOffset 2: ${offset2
script : }${script}` :
offset0 + "\n" + offset1 + "\n" + offset2); `${offset0}\n${offset1}\n${offset2}`);
}, },

View file

@ -145,11 +145,11 @@ const BitwiseOp = {
result = BitwiseOp._bitOp(input, Utils.hexToByteArray(key.toString(16)), BitwiseOp._xor, nullPreserving, differential); result = BitwiseOp._bitOp(input, Utils.hexToByteArray(key.toString(16)), BitwiseOp._xor, nullPreserving, differential);
resultUtf8 = Utils.byteArrayToUtf8(result); resultUtf8 = Utils.byteArrayToUtf8(result);
if (crib !== "" && resultUtf8.search(regex) === -1) continue; if (crib !== "" && resultUtf8.search(regex) === -1) continue;
if (printKey) output += "Key = " + Utils.hex(key, (2*keyLength)) + ": "; if (printKey) output += `Key = ${Utils.hex(key, (2*keyLength))}: `;
if (outputHex) if (outputHex)
output += Utils.byteArrayToHex(result) + "\n"; output += `${Utils.byteArrayToHex(result)}\n`;
else else
output += Utils.printable(resultUtf8, false) + "\n"; output += `${Utils.printable(resultUtf8, false)}\n`;
if (printKey) output += "\n"; if (printKey) output += "\n";
} }
return output; return output;

View file

@ -357,7 +357,7 @@ const ByteRepr = {
const convert = args[0]; const convert = args[0];
const spaces = args[1]; const spaces = args[1];
if (convert === "All chars") { if (convert === "All chars") {
let result = "|" + Utils.toHex(input) + "|"; let result = `|${Utils.toHex(input)}|`;
if (!spaces) result = result.replace(/ /g, ""); if (!spaces) result = result.replace(/ /g, "");
return result; return result;
} }

View file

@ -83,10 +83,10 @@ const Cipher = {
let result = ""; let result = "";
if (resultOption === "show all") { if (resultOption === "show all") {
result += "Key: " + encrypted.key.toString(Utils.format[outputFormat]); result += `Key: ${encrypted.key.toString(Utils.format[outputFormat])}`;
result += "\nIV: " + encrypted.iv.toString(Utils.format[outputFormat]); result += `\nIV: ${encrypted.iv.toString(Utils.format[outputFormat])}`;
if (encrypted.salt) result += "\nSalt: " + encrypted.salt.toString(Utils.format[outputFormat]); if (encrypted.salt) result += `\nSalt: ${encrypted.salt.toString(Utils.format[outputFormat])}`;
result += "\n\nCiphertext: " + encrypted.ciphertext.toString(Utils.format[outputFormat]); result += `\n\nCiphertext: ${encrypted.ciphertext.toString(Utils.format[outputFormat])}`;
} else { } else {
result = encrypted[resultOption].toString(Utils.format[outputFormat]); result = encrypted[resultOption].toString(Utils.format[outputFormat]);
} }
@ -138,7 +138,7 @@ const Cipher = {
try { try {
result = decrypted.toString(Utils.format[outputFormat]); result = decrypted.toString(Utils.format[outputFormat]);
} catch (err) { } catch (err) {
result = "Decrypt error: " + err.message; result = `Decrypt error: ${err.message}`;
} }
return result; return result;

View file

@ -39,7 +39,7 @@ const Code = {
runSyntaxHighlight: function(input, args) { runSyntaxHighlight: function(input, args) {
let language = args[0], let language = args[0],
lineNums = args[1]; lineNums = args[1];
return "<code class='prettyprint'>" + prettyPrintOne(Utils.escapeHtml(input), language, lineNums) + "</code>"; return `<code class='prettyprint'>${prettyPrintOne(Utils.escapeHtml(input), language, lineNums)}</code>`;
}, },
@ -302,9 +302,9 @@ const Code = {
*/ */
function preserveToken(str, match, t) { function preserveToken(str, match, t) {
preservedTokens[t] = match[0]; preservedTokens[t] = match[0];
return str.substring(0, match.index) + return `${str.substring(0, match.index)
"###preservedToken" + t + "###" + }###preservedToken${t}###${
str.substring(match.index + match[0].length); str.substring(match.index + match[0].length)}`;
} }
}, },
@ -344,7 +344,7 @@ const Code = {
try { try {
nodes = xpath.select(query, doc); nodes = xpath.select(query, doc);
} catch (err) { } catch (err) {
return "Invalid XPath. Details:\n" + err.message; return `Invalid XPath. Details:\n${err.message}`;
} }
const nodeToString = function(node) { const nodeToString = function(node) {
@ -396,7 +396,7 @@ const Code = {
try { try {
result = html.querySelectorAll(query); result = html.querySelectorAll(query);
} catch (err) { } catch (err) {
return "Invalid CSS Selector. Details:\n" + err.message; return `Invalid CSS Selector. Details:\n${err.message}`;
} }
const nodeToString = function(node) { const nodeToString = function(node) {
@ -406,7 +406,7 @@ const Code = {
case Node.COMMENT_NODE: return node.data; case Node.COMMENT_NODE: return node.data;
case Node.TEXT_NODE: return node.wholeText; case Node.TEXT_NODE: return node.wholeText;
case Node.DOCUMENT_NODE: return node.outerHTML; case Node.DOCUMENT_NODE: return node.outerHTML;
default: throw new Error("Unknown Node Type: " + node.nodeType); default: throw new Error(`Unknown Node Type: ${node.nodeType}`);
} }
}; };

View file

@ -30,16 +30,16 @@ const DateTime = {
if (units === "Seconds (s)") { if (units === "Seconds (s)") {
d = moment.unix(input); d = moment.unix(input);
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss") + " UTC"; return `${d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss")} UTC`;
} else if (units === "Milliseconds (ms)") { } else if (units === "Milliseconds (ms)") {
d = moment(input); d = moment(input);
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS") + " UTC"; return `${d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS")} UTC`;
} else if (units === "Microseconds (μs)") { } else if (units === "Microseconds (μs)") {
d = moment(input / 1000); d = moment(input / 1000);
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS") + " UTC"; return `${d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS")} UTC`;
} else if (units === "Nanoseconds (ns)") { } else if (units === "Nanoseconds (ns)") {
d = moment(input / 1000000); d = moment(input / 1000000);
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS") + " UTC"; return `${d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS")} UTC`;
} else { } else {
throw "Unrecognised unit"; throw "Unrecognised unit";
} }
@ -146,7 +146,7 @@ const DateTime = {
date = moment.tz(input, inputFormat, inputTimezone); date = moment.tz(input, inputFormat, inputTimezone);
if (!date || date.format() === "Invalid date") throw Error; if (!date || date.format() === "Invalid date") throw Error;
} catch (err) { } catch (err) {
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES; return `Invalid format.\n\n${DateTime.FORMAT_EXAMPLES}`;
} }
return date.tz(outputTimezone).format(outputFormat); return date.tz(outputTimezone).format(outputFormat);
@ -170,20 +170,20 @@ const DateTime = {
date = moment.tz(input, inputFormat, inputTimezone); date = moment.tz(input, inputFormat, inputTimezone);
if (!date || date.format() === "Invalid date") throw Error; if (!date || date.format() === "Invalid date") throw Error;
} catch (err) { } catch (err) {
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES; return `Invalid format.\n\n${DateTime.FORMAT_EXAMPLES}`;
} }
output += "Date: " + date.format("dddd Do MMMM YYYY") + output += `Date: ${date.format("dddd Do MMMM YYYY")
"\nTime: " + date.format("HH:mm:ss") + }\nTime: ${date.format("HH:mm:ss")
"\nPeriod: " + date.format("A") + }\nPeriod: ${date.format("A")
"\nTimezone: " + date.format("z") + }\nTimezone: ${date.format("z")
"\nUTC offset: " + date.format("ZZ") + }\nUTC offset: ${date.format("ZZ")
"\n\nDaylight Saving Time: " + date.isDST() + }\n\nDaylight Saving Time: ${date.isDST()
"\nLeap year: " + date.isLeapYear() + }\nLeap year: ${date.isLeapYear()
"\nDays in this month: " + date.daysInMonth() + }\nDays in this month: ${date.daysInMonth()
"\n\nDay of year: " + date.dayOfYear() + }\n\nDay of year: ${date.dayOfYear()
"\nWeek number: " + date.weekYear() + }\nWeek number: ${date.weekYear()
"\nQuarter: " + date.quarter(); }\nQuarter: ${date.quarter()}`;
return output; return output;
}, },

View file

@ -30,16 +30,16 @@ const Entropy = {
output = "", output = "",
entropy = Entropy._calcEntropy(input); entropy = Entropy._calcEntropy(input);
output += "Shannon entropy: " + entropy + "\n" + output += `Shannon entropy: ${entropy}\n` +
"<br><canvas id='chart-area'></canvas><br>\n" + "<br><canvas id='chart-area'></canvas><br>\n" +
"- 0 represents no randomness (i.e. all the bytes in the data have the same value) whereas 8, the maximum, represents a completely random string.\n" + "- 0 represents no randomness (i.e. all the bytes in the data have the same value) whereas 8, the maximum, represents a completely random string.\n" +
"- Standard English text usually falls somewhere between 3.5 and 5.\n" + "- Standard English text usually falls somewhere between 3.5 and 5.\n" +
"- Properly encrypted or compressed data of a reasonable length should have an entropy of over 7.5.\n\n" + "- Properly encrypted or compressed data of a reasonable length should have an entropy of over 7.5.\n\n" +
"The following results show the entropy of chunks of the input data. Chunks with particularly high entropy could suggest encrypted or compressed sections.\n\n" + "The following results show the entropy of chunks of the input data. Chunks with particularly high entropy could suggest encrypted or compressed sections.\n\n" +
"<br><script>\ `<br><script>\
var canvas = document.getElementById('chart-area'),\ var canvas = document.getElementById('chart-area'),\
parentRect = canvas.parentNode.getBoundingClientRect(),\ parentRect = canvas.parentNode.getBoundingClientRect(),\
entropy = " + entropy + ",\ entropy = ${entropy},\
height = parentRect.height * 0.25;\ height = parentRect.height * 0.25;\
\ \
canvas.width = parentRect.width * 0.95;\ canvas.width = parentRect.width * 0.95;\
@ -56,13 +56,13 @@ const Entropy = {
max: 8\ max: 8\
}\ }\
]);\ ]);\
</script>"; </script>`;
let chunkEntropy = 0; let chunkEntropy = 0;
if (chunkSize !== 0) { if (chunkSize !== 0) {
for (let i = 0; i < input.length; i += chunkSize) { for (let i = 0; i < input.length; i += chunkSize) {
chunkEntropy = Entropy._calcEntropy(input.slice(i, i+chunkSize)); chunkEntropy = Entropy._calcEntropy(input.slice(i, i+chunkSize));
output += "Bytes " + i + " to " + (i+chunkSize) + ": " + chunkEntropy + "\n"; output += `Bytes ${i} to ${i+chunkSize}: ${chunkEntropy}\n`;
} }
} else { } else {
output += "Chunk size cannot be 0."; output += "Chunk size cannot be 0.";
@ -107,27 +107,27 @@ const Entropy = {
} }
// Print // Print
let output = "<canvas id='chart-area'></canvas><br>" + let output = `${"<canvas id='chart-area'></canvas><br>" +
"Total data length: " + len + "Total data length: "}${len
"\nNumber of bytes represented: " + repr + }\nNumber of bytes represented: ${repr
"\nNumber of bytes not represented: " + (256-repr) + }\nNumber of bytes not represented: ${256-repr
"\n\nByte Percentage\n" + }\n\nByte Percentage\n` +
"<script>\ `<script>\
var canvas = document.getElementById('chart-area'),\ var canvas = document.getElementById('chart-area'),\
parentRect = canvas.parentNode.getBoundingClientRect(),\ parentRect = canvas.parentNode.getBoundingClientRect(),\
scores = " + JSON.stringify(percentages) + ";\ scores = ${JSON.stringify(percentages)};\
\ \
canvas.width = parentRect.width * 0.95;\ canvas.width = parentRect.width * 0.95;\
canvas.height = parentRect.height * 0.9;\ canvas.height = parentRect.height * 0.9;\
\ \
CanvasComponents.drawBarChart(canvas, scores, 'Byte', 'Frequency %', 16, 6);\ CanvasComponents.drawBarChart(canvas, scores, 'Byte', 'Frequency %', 16, 6);\
</script>"; </script>`;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
if (distrib[i] || showZeroes) { if (distrib[i] || showZeroes) {
output += " " + Utils.hex(i, 2) + " (" + output += ` ${Utils.hex(i, 2)} (${
Utils.padRight(percentages[i].toFixed(2).replace(".00", "") + "%)", 8) + Utils.padRight(`${percentages[i].toFixed(2).replace(".00", "")}%)`, 8)
Array(Math.ceil(percentages[i])+1).join("|") + "\n"; }${Array(Math.ceil(percentages[i])+1).join("|")}\n`;
} }
} }

View file

@ -29,11 +29,11 @@ const Extract = {
if (removeRegex && removeRegex.test(match[0])) if (removeRegex && removeRegex.test(match[0]))
continue; continue;
total++; total++;
output += match[0] + "\n"; output += `${match[0]}\n`;
} }
if (includeTotal) if (includeTotal)
output = "Total found: " + total + "\n\n" + output; output = `Total found: ${total}\n\n${output}`;
return output; return output;
}, },
@ -61,7 +61,7 @@ const Extract = {
let minLen = args[0] || Extract.MIN_STRING_LEN, let minLen = args[0] || Extract.MIN_STRING_LEN,
displayTotal = args[1], displayTotal = args[1],
strings = "[A-Z\\d/\\-:.,_$%'\"()<>= !\\[\\]{}@]", strings = "[A-Z\\d/\\-:.,_$%'\"()<>= !\\[\\]{}@]",
regex = new RegExp(strings + "{" + minLen + ",}", "ig"); regex = new RegExp(`${strings}{${minLen},}`, "ig");
return Extract._search(input, regex, null, displayTotal); return Extract._search(input, regex, null, displayTotal);
}, },
@ -100,7 +100,7 @@ const Extract = {
ips = ""; ips = "";
if (includeIpv4 && includeIpv6) { if (includeIpv4 && includeIpv6) {
ips = ipv4 + "|" + ipv6; ips = `${ipv4}|${ipv6}`;
} else if (includeIpv4) { } else if (includeIpv4) {
ips = ipv4; ips = ipv4;
} else if (includeIpv6) { } else if (includeIpv6) {
@ -115,8 +115,8 @@ const Extract = {
oneninetwo = "192\\.168\\..+", oneninetwo = "192\\.168\\..+",
oneseventwo = "172\\.(?:1[6-9]|2\\d|3[01])\\..+", oneseventwo = "172\\.(?:1[6-9]|2\\d|3[01])\\..+",
onetwoseven = "127\\..+", onetwoseven = "127\\..+",
removeRegex = new RegExp("^(?:" + ten + "|" + oneninetwo + removeRegex = new RegExp(`^(?:${ten}|${oneninetwo
"|" + oneseventwo + "|" + onetwoseven + ")"); }|${oneseventwo}|${onetwoseven})`);
return Extract._search(input, regex, removeRegex, displayTotal); return Extract._search(input, regex, removeRegex, displayTotal);
} else { } else {
@ -173,8 +173,8 @@ const Extract = {
path = "/[^.!,?;\"'<>()\\[\\]{}\\s\\x7F-\\xFF]*"; path = "/[^.!,?;\"'<>()\\[\\]{}\\s\\x7F-\\xFF]*";
path += "(?:[.!,?]+[^.!,?;\"'<>()\\[\\]{}\\s\\x7F-\\xFF]+)*"; path += "(?:[.!,?]+[^.!,?;\"'<>()\\[\\]{}\\s\\x7F-\\xFF]+)*";
const regex = new RegExp(protocol + hostname + "(?:" + port + const regex = new RegExp(`${protocol + hostname}(?:${port
")?(?:" + path + ")?", "ig"); })?(?:${path})?`, "ig");
return Extract._search(input, regex, null, displayTotal); return Extract._search(input, regex, null, displayTotal);
}, },
@ -191,7 +191,7 @@ const Extract = {
protocol = "https?://", protocol = "https?://",
hostname = "[-\\w\\.]+", hostname = "[-\\w\\.]+",
tld = "\\.(?:com|net|org|biz|info|co|uk|onion|int|mobi|name|edu|gov|mil|eu|ac|ae|af|de|ca|ch|cn|cy|es|gb|hk|il|in|io|tv|me|nl|no|nz|ro|ru|tr|us|az|ir|kz|uz|pk)+", tld = "\\.(?:com|net|org|biz|info|co|uk|onion|int|mobi|name|edu|gov|mil|eu|ac|ae|af|de|ca|ch|cn|cy|es|gb|hk|il|in|io|tv|me|nl|no|nz|ro|ru|tr|us|az|ir|kz|uz|pk)+",
regex = new RegExp("(?:" + protocol + ")?" + hostname + tld, "ig"); regex = new RegExp(`(?:${protocol})?${hostname}${tld}`, "ig");
return Extract._search(input, regex, null, displayTotal); return Extract._search(input, regex, null, displayTotal);
}, },
@ -222,13 +222,13 @@ const Extract = {
winDrive = "[A-Z]:\\\\", winDrive = "[A-Z]:\\\\",
winName = "[A-Z\\d][A-Z\\d\\- '_\\(\\)]{0,61}", winName = "[A-Z\\d][A-Z\\d\\- '_\\(\\)]{0,61}",
winExt = "[A-Z\\d]{1,6}", winExt = "[A-Z\\d]{1,6}",
winPath = winDrive + "(?:" + winName + "\\\\?)*" + winName + winPath = `${winDrive}(?:${winName}\\\\?)*${winName
"(?:\\." + winExt + ")?", }(?:\\.${winExt})?`,
unixPath = "(?:/[A-Z\\d.][A-Z\\d\\-.]{0,61})+", unixPath = "(?:/[A-Z\\d.][A-Z\\d\\-.]{0,61})+",
filePaths = ""; filePaths = "";
if (includeWinPath && includeUnixPath) { if (includeWinPath && includeUnixPath) {
filePaths = winPath + "|" + unixPath; filePaths = `${winPath}|${unixPath}`;
} else if (includeWinPath) { } else if (includeWinPath) {
filePaths = winPath; filePaths = winPath;
} else if (includeUnixPath) { } else if (includeUnixPath) {
@ -256,7 +256,7 @@ const Extract = {
date1 = "(?:19|20)\\d\\d[- /.](?:0[1-9]|1[012])[- /.](?:0[1-9]|[12][0-9]|3[01])", // yyyy-mm-dd date1 = "(?:19|20)\\d\\d[- /.](?:0[1-9]|1[012])[- /.](?:0[1-9]|[12][0-9]|3[01])", // yyyy-mm-dd
date2 = "(?:0[1-9]|[12][0-9]|3[01])[- /.](?:0[1-9]|1[012])[- /.](?:19|20)\\d\\d", // dd/mm/yyyy date2 = "(?:0[1-9]|[12][0-9]|3[01])[- /.](?:0[1-9]|1[012])[- /.](?:19|20)\\d\\d", // dd/mm/yyyy
date3 = "(?:0[1-9]|1[012])[- /.](?:0[1-9]|[12][0-9]|3[01])[- /.](?:19|20)\\d\\d", // mm/dd/yyyy date3 = "(?:0[1-9]|1[012])[- /.](?:0[1-9]|[12][0-9]|3[01])[- /.](?:19|20)\\d\\d", // mm/dd/yyyy
regex = new RegExp(date1 + "|" + date2 + "|" + date3, "ig"); regex = new RegExp(`${date1}|${date2}|${date3}`, "ig");
return Extract._search(input, regex, null, displayTotal); return Extract._search(input, regex, null, displayTotal);
}, },

View file

@ -25,11 +25,11 @@ const FileType = {
if (!type) { if (!type) {
return "Unknown file type. Have you tried checking the entropy of this data to determine whether it might be encrypted or compressed?"; return "Unknown file type. Have you tried checking the entropy of this data to determine whether it might be encrypted or compressed?";
} else { } else {
let output = "File extension: " + type.ext + "\n" + let output = `File extension: ${type.ext}\n` +
"MIME type: " + type.mime; `MIME type: ${type.mime}`;
if (type.desc && type.desc.length) { if (type.desc && type.desc.length) {
output += "\nDescription: " + type.desc; output += `\nDescription: ${type.desc}`;
} }
return output; return output;
@ -66,12 +66,12 @@ const FileType = {
continue; continue;
} }
numFound++; numFound++;
output += "\nOffset " + i + " (0x" + Utils.hex(i) + "):\n" + output += `\nOffset ${i} (0x${Utils.hex(i)}):\n` +
" File extension: " + type.ext + "\n" + ` File extension: ${type.ext}\n` +
" MIME type: " + type.mime + "\n"; ` MIME type: ${type.mime}\n`;
if (type.desc && type.desc.length) { if (type.desc && type.desc.length) {
output += " Description: " + type.desc + "\n"; output += ` Description: ${type.desc}\n`;
} }
} }
} }
@ -81,7 +81,7 @@ const FileType = {
} }
if (numCommonFound > 0) { if (numCommonFound > 0) {
output += "\n\n" + numCommonFound; output += `\n\n${numCommonFound}`;
output += numCommonFound === 1 ? output += numCommonFound === 1 ?
" file type was detected that has a common byte sequence. This is likely to be a false positive." : " file type was detected that has a common byte sequence. This is likely to be a false positive." :
" file types were detected that have common byte sequences. These are likely to be false positives."; " file types were detected that have common byte sequences. These are likely to be false positives.";

View file

@ -40,27 +40,27 @@ const HTML = {
for (let i = 0; i < charcodes.length; i++) { for (let i = 0; i < charcodes.length; i++) {
if (convertAll && numeric) { if (convertAll && numeric) {
output += "&#" + charcodes[i] + ";"; output += `&#${charcodes[i]};`;
} else if (convertAll && hexa) { } else if (convertAll && hexa) {
output += "&#x" + Utils.hex(charcodes[i]) + ";"; output += `&#x${Utils.hex(charcodes[i])};`;
} else if (convertAll) { } else if (convertAll) {
output += HTML._byteToEntity[charcodes[i]] || "&#" + charcodes[i] + ";"; output += HTML._byteToEntity[charcodes[i]] || `&#${charcodes[i]};`;
} else if (numeric) { } else if (numeric) {
if (charcodes[i] > 255 || HTML._byteToEntity.hasOwnProperty(charcodes[i])) { if (charcodes[i] > 255 || HTML._byteToEntity.hasOwnProperty(charcodes[i])) {
output += "&#" + charcodes[i] + ";"; output += `&#${charcodes[i]};`;
} else { } else {
output += Utils.chr(charcodes[i]); output += Utils.chr(charcodes[i]);
} }
} else if (hexa) { } else if (hexa) {
if (charcodes[i] > 255 || HTML._byteToEntity.hasOwnProperty(charcodes[i])) { if (charcodes[i] > 255 || HTML._byteToEntity.hasOwnProperty(charcodes[i])) {
output += "&#x" + Utils.hex(charcodes[i]) + ";"; output += `&#x${Utils.hex(charcodes[i])};`;
} else { } else {
output += Utils.chr(charcodes[i]); output += Utils.chr(charcodes[i]);
} }
} else { } else {
output += HTML._byteToEntity[charcodes[i]] || ( output += HTML._byteToEntity[charcodes[i]] || (
charcodes[i] > 255 ? charcodes[i] > 255 ?
"&#" + charcodes[i] + ";" : `&#${charcodes[i]};` :
Utils.chr(charcodes[i]) Utils.chr(charcodes[i])
); );
} }
@ -213,28 +213,28 @@ const HTML = {
y = isNaN(y) ? "0" : y.toFixed(2); y = isNaN(y) ? "0" : y.toFixed(2);
k = k.toFixed(2); k = k.toFixed(2);
let hex = "#" + let hex = `#${
Utils.padLeft(Math.round(r).toString(16), 2) + Utils.padLeft(Math.round(r).toString(16), 2)
Utils.padLeft(Math.round(g).toString(16), 2) + }${Utils.padLeft(Math.round(g).toString(16), 2)
Utils.padLeft(Math.round(b).toString(16), 2), }${Utils.padLeft(Math.round(b).toString(16), 2)}`,
rgb = "rgb(" + r + ", " + g + ", " + b + ")", rgb = `rgb(${r}, ${g}, ${b})`,
rgba = "rgba(" + r + ", " + g + ", " + b + ", " + a + ")", rgba = `rgba(${r}, ${g}, ${b}, ${a})`,
hsl = "hsl(" + h + ", " + s + "%, " + l + "%)", hsl = `hsl(${h}, ${s}%, ${l}%)`,
hsla = "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")", hsla = `hsla(${h}, ${s}%, ${l}%, ${a})`,
cmyk = "cmyk(" + c + ", " + m + ", " + y + ", " + k + ")"; cmyk = `cmyk(${c}, ${m}, ${y}, ${k})`;
// Generate output // Generate output
return "<div id='colorpicker' style='display: inline-block'></div>" + return `${"<div id='colorpicker' style='display: inline-block'></div>" +
"Hex: " + hex + "\n" + "Hex: "}${hex}\n` +
"RGB: " + rgb + "\n" + `RGB: ${rgb}\n` +
"RGBA: " + rgba + "\n" + `RGBA: ${rgba}\n` +
"HSL: " + hsl + "\n" + `HSL: ${hsl}\n` +
"HSLA: " + hsla + "\n" + `HSLA: ${hsla}\n` +
"CMYK: " + cmyk + `CMYK: ${cmyk
"<script>\ }<script>\
$('#colorpicker').colorpicker({\ $('#colorpicker').colorpicker({\
format: 'rgba',\ format: 'rgba',\
color: '" + rgba + "',\ color: '${rgba}',\
container: true,\ container: true,\
inline: true,\ inline: true,\
}).on('changeColor', function(e) {\ }).on('changeColor', function(e) {\
@ -243,7 +243,7 @@ const HTML = {
color.r + ', ' + color.g + ', ' + color.b + ', ' + color.a + ')';\ color.r + ', ' + color.g + ', ' + color.b + ', ' + color.a + ')';\
window.app.autoBake();\ window.app.autoBake();\
});\ });\
</script>"; </script>`;
}, },

View file

@ -37,18 +37,18 @@ const HTTP = {
runParseUserAgent: function(input, args) { runParseUserAgent: function(input, args) {
const ua = UAParser.parse(input); const ua = UAParser.parse(input);
return "Type: " + ua.type + "\n" + return `Type: ${ua.type}\n` +
"Family: " + ua.uaFamily + "\n" + `Family: ${ua.uaFamily}\n` +
"Name: " + ua.uaName + "\n" + `Name: ${ua.uaName}\n` +
"URL: " + ua.uaUrl + "\n" + `URL: ${ua.uaUrl}\n` +
"Company: " + ua.uaCompany + "\n" + `Company: ${ua.uaCompany}\n` +
"Company URL: " + ua.uaCompanyUrl + "\n\n" + `Company URL: ${ua.uaCompanyUrl}\n\n` +
"OS Family: " + ua.osFamily + "\n" + `OS Family: ${ua.osFamily}\n` +
"OS Name: " + ua.osName + "\n" + `OS Name: ${ua.osName}\n` +
"OS URL: " + ua.osUrl + "\n" + `OS URL: ${ua.osUrl}\n` +
"OS Company: " + ua.osCompany + "\n" + `OS Company: ${ua.osCompany}\n` +
"OS Company URL: " + ua.osCompanyUrl + "\n" + `OS Company URL: ${ua.osCompanyUrl}\n` +
"Device Type: " + ua.deviceType + "\n"; `Device Type: ${ua.deviceType}\n`;
}, },
}; };

View file

@ -204,27 +204,27 @@ const Hash = {
*/ */
runAll: function (input, args) { runAll: function (input, args) {
let byteArray = Utils.strToByteArray(input), let byteArray = Utils.strToByteArray(input),
output = "MD2: " + Hash.runMD2(input, []) + output = `MD2: ${Hash.runMD2(input, [])
"\nMD4: " + Hash.runMD4(input, []) + }\nMD4: ${Hash.runMD4(input, [])
"\nMD5: " + Hash.runMD5(input, []) + }\nMD5: ${Hash.runMD5(input, [])
"\nSHA0: " + Hash.runSHA0(input, []) + }\nSHA0: ${Hash.runSHA0(input, [])
"\nSHA1: " + Hash.runSHA1(input, []) + }\nSHA1: ${Hash.runSHA1(input, [])
"\nSHA2 224: " + Hash.runSHA224(input, []) + }\nSHA2 224: ${Hash.runSHA224(input, [])
"\nSHA2 256: " + Hash.runSHA256(input, []) + }\nSHA2 256: ${Hash.runSHA256(input, [])
"\nSHA2 384: " + Hash.runSHA384(input, []) + }\nSHA2 384: ${Hash.runSHA384(input, [])
"\nSHA2 512: " + Hash.runSHA512(input, []) + }\nSHA2 512: ${Hash.runSHA512(input, [])
"\nSHA3 224: " + Hash.runSHA3(input, ["224"]) + }\nSHA3 224: ${Hash.runSHA3(input, ["224"])
"\nSHA3 256: " + Hash.runSHA3(input, ["256"]) + }\nSHA3 256: ${Hash.runSHA3(input, ["256"])
"\nSHA3 384: " + Hash.runSHA3(input, ["384"]) + }\nSHA3 384: ${Hash.runSHA3(input, ["384"])
"\nSHA3 512: " + Hash.runSHA3(input, ["512"]) + }\nSHA3 512: ${Hash.runSHA3(input, ["512"])
"\nRIPEMD-160: " + Hash.runRIPEMD160(input, []) + }\nRIPEMD-160: ${Hash.runRIPEMD160(input, [])
"\n\nChecksums:" + }\n\nChecksums:` +
"\nFletcher-8: " + Checksum.runFletcher8(byteArray, []) + `\nFletcher-8: ${Checksum.runFletcher8(byteArray, [])
"\nFletcher-16: " + Checksum.runFletcher16(byteArray, []) + }\nFletcher-16: ${Checksum.runFletcher16(byteArray, [])
"\nFletcher-32: " + Checksum.runFletcher32(byteArray, []) + }\nFletcher-32: ${Checksum.runFletcher32(byteArray, [])
"\nFletcher-64: " + Checksum.runFletcher64(byteArray, []) + }\nFletcher-64: ${Checksum.runFletcher64(byteArray, [])
"\nAdler-32: " + Checksum.runAdler32(byteArray, []) + }\nAdler-32: ${Checksum.runAdler32(byteArray, [])
"\nCRC-32: " + Checksum.runCRC32(byteArray, []); }\nCRC-32: ${Checksum.runCRC32(byteArray, [])}`;
return output; return output;
}, },
@ -249,9 +249,9 @@ const Hash = {
return "Invalid hash"; return "Invalid hash";
} }
output += "Hash length: " + input.length + "\n" + output += `Hash length: ${input.length}\n` +
"Byte length: " + byteLength + "\n" + `Byte length: ${byteLength}\n` +
"Bit length: " + bitLength + "\n\n" + `Bit length: ${bitLength}\n\n` +
"Based on the length, this hash could have been generated by one of the following hashing functions:\n"; "Based on the length, this hash could have been generated by one of the following hashing functions:\n";
switch (bitLength) { switch (bitLength) {

View file

@ -46,7 +46,7 @@ const Hexdump = {
const buff = input.slice(i, i+length); const buff = input.slice(i, i+length);
let hexa = ""; let hexa = "";
for (let j = 0; j < buff.length; j++) { for (let j = 0; j < buff.length; j++) {
hexa += Utils.hex(buff[j], padding) + " "; hexa += `${Utils.hex(buff[j], padding)} `;
} }
let lineNo = Utils.hex(i, 8); let lineNo = Utils.hex(i, 8);
@ -56,12 +56,12 @@ const Hexdump = {
lineNo = lineNo.toUpperCase(); lineNo = lineNo.toUpperCase();
} }
output += lineNo + " " + output += `${lineNo} ${
Utils.padRight(hexa, (length*(padding+1))) + Utils.padRight(hexa, (length*(padding+1)))
" |" + Utils.padRight(Utils.printable(Utils.byteArrayToChars(buff)), buff.length) + "|\n"; } |${Utils.padRight(Utils.printable(Utils.byteArrayToChars(buff)), buff.length)}|\n`;
if (includeFinalLength && i+buff.length === input.length) { if (includeFinalLength && i+buff.length === input.length) {
output += Utils.hex(i+buff.length, 8) + "\n"; output += `${Utils.hex(i+buff.length, 8)}\n`;
} }
} }

View file

@ -90,7 +90,7 @@ const IP = {
longhand = IP._ipv6ToStr(ipv6), longhand = IP._ipv6ToStr(ipv6),
shorthand = IP._ipv6ToStr(ipv6, true); shorthand = IP._ipv6ToStr(ipv6, true);
output += "Longhand: " + longhand + "\nShorthand: " + shorthand + "\n"; output += `Longhand: ${longhand}\nShorthand: ${shorthand}\n`;
// Detect reserved addresses // Detect reserved addresses
if (shorthand === "::") { if (shorthand === "::") {
@ -105,13 +105,13 @@ const IP = {
ipv6[3] === 0 && ipv6[4] === 0 && ipv6[5] === 0xffff) { ipv6[3] === 0 && ipv6[4] === 0 && ipv6[5] === 0xffff) {
// IPv4-mapped IPv6 address // IPv4-mapped IPv6 address
output += "\nIPv4-mapped IPv6 address detected. IPv6 clients will be handled natively by default, and IPv4 clients appear as IPv6 clients at their IPv4-mapped IPv6 address."; output += "\nIPv4-mapped IPv6 address detected. IPv6 clients will be handled natively by default, and IPv4 clients appear as IPv6 clients at their IPv4-mapped IPv6 address.";
output += "\nMapped IPv4 address: " + IP._ipv4ToStr((ipv6[6] << 16) + ipv6[7]); output += `\nMapped IPv4 address: ${IP._ipv4ToStr((ipv6[6] << 16) + ipv6[7])}`;
output += "\nIPv4-mapped IPv6 addresses range: ::ffff:0:0/96"; output += "\nIPv4-mapped IPv6 addresses range: ::ffff:0:0/96";
} else if (ipv6[0] === 0 && ipv6[1] === 0 && ipv6[2] === 0 && } else if (ipv6[0] === 0 && ipv6[1] === 0 && ipv6[2] === 0 &&
ipv6[3] === 0 && ipv6[4] === 0xffff && ipv6[5] === 0) { ipv6[3] === 0 && ipv6[4] === 0xffff && ipv6[5] === 0) {
// IPv4-translated address // IPv4-translated address
output += "\nIPv4-translated address detected. Used by Stateless IP/ICMP Translation (SIIT). See RFCs 6145 and 6052 for more details."; output += "\nIPv4-translated address detected. Used by Stateless IP/ICMP Translation (SIIT). See RFCs 6145 and 6052 for more details.";
output += "\nTranslated IPv4 address: " + IP._ipv4ToStr((ipv6[6] << 16) + ipv6[7]); output += `\nTranslated IPv4 address: ${IP._ipv4ToStr((ipv6[6] << 16) + ipv6[7])}`;
output += "\nIPv4-translated addresses range: ::ffff:0:0:0/96"; output += "\nIPv4-translated addresses range: ::ffff:0:0:0/96";
} else if (ipv6[0] === 0x100) { } else if (ipv6[0] === 0x100) {
// Discard prefix per RFC 6666 // Discard prefix per RFC 6666
@ -121,7 +121,7 @@ const IP = {
ipv6[3] === 0 && ipv6[4] === 0 && ipv6[5] === 0) { ipv6[3] === 0 && ipv6[4] === 0 && ipv6[5] === 0) {
// IPv4/IPv6 translation per RFC 6052 // IPv4/IPv6 translation per RFC 6052
output += "\n'Well-Known' prefix for IPv4/IPv6 translation detected. See RFC 6052 for more details."; output += "\n'Well-Known' prefix for IPv4/IPv6 translation detected. See RFC 6052 for more details.";
output += "\nTranslated IPv4 address: " + IP._ipv4ToStr((ipv6[6] << 16) + ipv6[7]); output += `\nTranslated IPv4 address: ${IP._ipv4ToStr((ipv6[6] << 16) + ipv6[7])}`;
output += "\n'Well-Known' prefix range: 64:ff9b::/96"; output += "\n'Well-Known' prefix range: 64:ff9b::/96";
} else if (ipv6[0] === 0x2001 && ipv6[1] === 0) { } else if (ipv6[0] === 0x2001 && ipv6[1] === 0) {
// Teredo tunneling // Teredo tunneling
@ -135,11 +135,11 @@ const IP = {
flagUg = (ipv6[4] >>> 8) & 3, flagUg = (ipv6[4] >>> 8) & 3,
flagRandom2 = ipv6[4] & 255; flagRandom2 = ipv6[4] & 255;
output += "\nServer IPv4 address: " + IP._ipv4ToStr(serverIpv4) + output += `\nServer IPv4 address: ${IP._ipv4ToStr(serverIpv4)
"\nClient IPv4 address: " + IP._ipv4ToStr(clientIpv4) + }\nClient IPv4 address: ${IP._ipv4ToStr(clientIpv4)
"\nClient UDP port: " + udpPort + }\nClient UDP port: ${udpPort
"\nFlags:" + }\nFlags:` +
"\n\tCone: " + flagCone; `\n\tCone: ${flagCone}`;
if (flagCone) { if (flagCone) {
output += " (Client is behind a cone NAT)"; output += " (Client is behind a cone NAT)";
@ -147,20 +147,20 @@ const IP = {
output += " (Client is not behind a cone NAT)"; output += " (Client is not behind a cone NAT)";
} }
output += "\n\tR: " + flagR; output += `\n\tR: ${flagR}`;
if (flagR) { if (flagR) {
output += " Error: This flag should be set to 0. See RFC 5991 and RFC 4380."; output += " Error: This flag should be set to 0. See RFC 5991 and RFC 4380.";
} }
output += "\n\tRandom1: " + Utils.bin(flagRandom1, 4) + output += `\n\tRandom1: ${Utils.bin(flagRandom1, 4)
"\n\tUG: " + Utils.bin(flagUg, 2); }\n\tUG: ${Utils.bin(flagUg, 2)}`;
if (flagUg) { if (flagUg) {
output += " Error: This flag should be set to 00. See RFC 4380."; output += " Error: This flag should be set to 00. See RFC 4380.";
} }
output += "\n\tRandom2: " + Utils.bin(flagRandom2, 8); output += `\n\tRandom2: ${Utils.bin(flagRandom2, 8)}`;
if (!flagR && !flagUg && flagRandom1 && flagRandom2) { if (!flagR && !flagUg && flagRandom1 && flagRandom2) {
output += "\n\nThis is a valid Teredo address which complies with RFC 4380 and RFC 5991."; output += "\n\nThis is a valid Teredo address which complies with RFC 4380 and RFC 5991.";
@ -195,10 +195,10 @@ const IP = {
interfaceIdStr = ipv6[4].toString(16) + ipv6[5].toString(16) + ipv6[6].toString(16) + ipv6[7].toString(16), interfaceIdStr = ipv6[4].toString(16) + ipv6[5].toString(16) + ipv6[6].toString(16) + ipv6[7].toString(16),
interfaceId = new BigInteger(interfaceIdStr, 16); interfaceId = new BigInteger(interfaceIdStr, 16);
output += "\n\nEncapsulated IPv4 address: " + v4Addr + output += `\n\nEncapsulated IPv4 address: ${v4Addr
"\nSLA ID: " + slaId + }\nSLA ID: ${slaId
"\nInterface ID (base 16): " + interfaceIdStr + }\nInterface ID (base 16): ${interfaceIdStr
"\nInterface ID (base 10): " + interfaceId.toString(); }\nInterface ID (base 10): ${interfaceId.toString()}`;
} else if (ipv6[0] >= 0xfc00 && ipv6[0] <= 0xfdff) { } else if (ipv6[0] >= 0xfc00 && ipv6[0] <= 0xfdff) {
// Unique local address // Unique local address
output += "\nThis is a unique local address comparable to the IPv4 private addresses 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. See RFC 4193 for more details."; output += "\nThis is a unique local address comparable to the IPv4 private addresses 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. See RFC 4193 for more details.";
@ -218,15 +218,15 @@ const IP = {
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."; output += "\n\nThis IPv6 address contains a modified EUI-64 address, identified by the presence of FF:FE in the 12th and 13th octets.";
let intIdent = Utils.hex(ipv6[4] >>> 8) + ":" + Utils.hex(ipv6[4] & 0xff) + ":" + let intIdent = `${Utils.hex(ipv6[4] >>> 8)}:${Utils.hex(ipv6[4] & 0xff)}:${
Utils.hex(ipv6[5] >>> 8) + ":" + Utils.hex(ipv6[5] & 0xff) + ":" + Utils.hex(ipv6[5] >>> 8)}:${Utils.hex(ipv6[5] & 0xff)}:${
Utils.hex(ipv6[6] >>> 8) + ":" + Utils.hex(ipv6[6] & 0xff) + ":" + Utils.hex(ipv6[6] >>> 8)}:${Utils.hex(ipv6[6] & 0xff)}:${
Utils.hex(ipv6[7] >>> 8) + ":" + Utils.hex(ipv6[7] & 0xff), Utils.hex(ipv6[7] >>> 8)}:${Utils.hex(ipv6[7] & 0xff)}`,
mac = Utils.hex((ipv6[4] >>> 8) ^ 2) + ":" + Utils.hex(ipv6[4] & 0xff) + ":" + mac = `${Utils.hex((ipv6[4] >>> 8) ^ 2)}:${Utils.hex(ipv6[4] & 0xff)}:${
Utils.hex(ipv6[5] >>> 8) + ":" + Utils.hex(ipv6[6] & 0xff) + ":" + Utils.hex(ipv6[5] >>> 8)}:${Utils.hex(ipv6[6] & 0xff)}:${
Utils.hex(ipv6[7] >>> 8) + ":" + Utils.hex(ipv6[7] & 0xff); Utils.hex(ipv6[7] >>> 8)}:${Utils.hex(ipv6[7] & 0xff)}`;
output += "\nInterface identifier: " + intIdent + output += `\nInterface identifier: ${intIdent
"\nMAC address: " + mac; }\nMAC address: ${mac}`;
} }
} else { } else {
return "Invalid IPv6 address"; return "Invalid IPv6 address";
@ -263,7 +263,7 @@ const IP = {
let decimal; let decimal;
if (inFormat === outFormat) { if (inFormat === outFormat) {
output += lines[i] + "\n"; output += `${lines[i]}\n`;
continue; continue;
} }
@ -298,20 +298,20 @@ const IP = {
case "Dotted Decimal": case "Dotted Decimal":
ddIp = ""; ddIp = "";
for (j = 0; j < baIp.length; j++) { for (j = 0; j < baIp.length; j++) {
ddIp += baIp[j] + "."; ddIp += `${baIp[j]}.`;
} }
output += ddIp.slice(0, ddIp.length-1) + "\n"; output += `${ddIp.slice(0, ddIp.length-1)}\n`;
break; break;
case "Decimal": case "Decimal":
decIp = ((baIp[0] << 24) | (baIp[1] << 16) | (baIp[2] << 8) | baIp[3]) >>> 0; decIp = ((baIp[0] << 24) | (baIp[1] << 16) | (baIp[2] << 8) | baIp[3]) >>> 0;
output += decIp.toString() + "\n"; output += `${decIp.toString()}\n`;
break; break;
case "Hex": case "Hex":
hexIp = ""; hexIp = "";
for (j = 0; j < baIp.length; j++) { for (j = 0; j < baIp.length; j++) {
hexIp += Utils.hex(baIp[j]); hexIp += Utils.hex(baIp[j]);
} }
output += hexIp + "\n"; output += `${hexIp}\n`;
break; break;
default: default:
throw "Unsupported output IP format"; throw "Unsupported output IP format";
@ -399,11 +399,11 @@ const IP = {
for (network in ipv4Networks) { for (network in ipv4Networks) {
ipv4Networks[network] = ipv4Networks[network].sort(); ipv4Networks[network] = ipv4Networks[network].sort();
output += IP._ipv4ToStr(network) + "/" + cidr + "\n"; output += `${IP._ipv4ToStr(network)}/${cidr}\n`;
if (!onlySubnets) { if (!onlySubnets) {
for (i = 0; i < ipv4Networks[network].length; i++) { for (i = 0; i < ipv4Networks[network].length; i++) {
output += " " + IP._ipv4ToStr(ipv4Networks[network][i]) + "\n"; output += ` ${IP._ipv4ToStr(ipv4Networks[network][i])}\n`;
} }
output += "\n"; output += "\n";
} }
@ -413,11 +413,11 @@ const IP = {
for (networkStr in ipv6Networks) { for (networkStr in ipv6Networks) {
//ipv6Networks[networkStr] = ipv6Networks[networkStr].sort(); TODO //ipv6Networks[networkStr] = ipv6Networks[networkStr].sort(); TODO
output += networkStr + "/" + cidr + "\n"; output += `${networkStr}/${cidr}\n`;
if (!onlySubnets) { if (!onlySubnets) {
for (i = 0; i < ipv6Networks[networkStr].length; i++) { for (i = 0; i < ipv6Networks[networkStr].length; i++) {
output += " " + IP._ipv6ToStr(ipv6Networks[networkStr][i], true) + "\n"; output += ` ${IP._ipv6ToStr(ipv6Networks[networkStr][i], true)}\n`;
} }
output += "\n"; output += "\n";
} }
@ -470,12 +470,12 @@ const IP = {
// Version // Version
if (version !== 4) { if (version !== 4) {
version = version + " (Error: for IPv4 headers, this should always be set to 4)"; version = `${version} (Error: for IPv4 headers, this should always be set to 4)`;
} }
// IHL // IHL
if (ihl < 5) { if (ihl < 5) {
ihl = ihl + " (Error: this should always be at least 5)"; ihl = `${ihl} (Error: this should always be at least 5)`;
} else if (ihl > 5) { } else if (ihl > 5) {
// sort out options... // sort out options...
const optionsLen = ihl * 4 - 20; const optionsLen = ihl * 4 - 20;
@ -490,36 +490,36 @@ const IP = {
givenChecksum = Utils.hex(checksum), givenChecksum = Utils.hex(checksum),
checksumResult; checksumResult;
if (correctChecksum === givenChecksum) { if (correctChecksum === givenChecksum) {
checksumResult = givenChecksum + " (correct)"; checksumResult = `${givenChecksum} (correct)`;
} else { } else {
checksumResult = givenChecksum + " (incorrect, should be " + correctChecksum + ")"; checksumResult = `${givenChecksum} (incorrect, should be ${correctChecksum})`;
} }
output = "<table class='table table-hover table-condensed table-bordered table-nonfluid'><tr><th>Field</th><th>Value</th></tr>" + output = `${"<table class='table table-hover table-condensed table-bordered table-nonfluid'><tr><th>Field</th><th>Value</th></tr>" +
"<tr><td>Version</td><td>" + version + "</td></tr>" + "<tr><td>Version</td><td>"}${version}</td></tr>` +
"<tr><td>Internet Header Length (IHL)</td><td>" + ihl + " (" + (ihl * 4) + " bytes)</td></tr>" + `<tr><td>Internet Header Length (IHL)</td><td>${ihl} (${ihl * 4} bytes)</td></tr>` +
"<tr><td>Differentiated Services Code Point (DSCP)</td><td>" + dscp + "</td></tr>" + `<tr><td>Differentiated Services Code Point (DSCP)</td><td>${dscp}</td></tr>` +
"<tr><td>Explicit Congestion Notification (ECN)</td><td>" + ecn + "</td></tr>" + `<tr><td>Explicit Congestion Notification (ECN)</td><td>${ecn}</td></tr>` +
"<tr><td>Total length</td><td>" + length + " bytes" + `<tr><td>Total length</td><td>${length} bytes` +
"\n IP header: " + (ihl * 4) + " bytes" + `\n IP header: ${ihl * 4} bytes` +
"\n Data: " + (length - ihl * 4) + " bytes</td></tr>" + `\n Data: ${length - ihl * 4} bytes</td></tr>` +
"<tr><td>Identification</td><td>0x" + Utils.hex(identification) + " (" + identification + ")</td></tr>" + `<tr><td>Identification</td><td>0x${Utils.hex(identification)} (${identification})</td></tr>` +
"<tr><td>Flags</td><td>0x" + Utils.hex(flags, 2) + `<tr><td>Flags</td><td>0x${Utils.hex(flags, 2)
"\n Reserved bit:" + (flags >> 2) + " (must be 0)" + }\n Reserved bit:${flags >> 2} (must be 0)` +
"\n Don't fragment:" + (flags >> 1 & 1) + `\n Don't fragment:${flags >> 1 & 1
"\n More fragments:" + (flags & 1) + "</td></tr>" + }\n More fragments:${flags & 1}</td></tr>` +
"<tr><td>Fragment offset</td><td>" + fragOffset + "</td></tr>" + `<tr><td>Fragment offset</td><td>${fragOffset}</td></tr>` +
"<tr><td>Time-To-Live</td><td>" + ttl + "</td></tr>" + `<tr><td>Time-To-Live</td><td>${ttl}</td></tr>` +
"<tr><td>Protocol</td><td>" + protocol + ", " + protocolInfo.protocol + " (" + protocolInfo.keyword + ")</td></tr>" + `<tr><td>Protocol</td><td>${protocol}, ${protocolInfo.protocol} (${protocolInfo.keyword})</td></tr>` +
"<tr><td>Header checksum</td><td>" + checksumResult + "</td></tr>" + `<tr><td>Header checksum</td><td>${checksumResult}</td></tr>` +
"<tr><td>Source IP address</td><td>" + IP._ipv4ToStr(srcIP) + "</td></tr>" + `<tr><td>Source IP address</td><td>${IP._ipv4ToStr(srcIP)}</td></tr>` +
"<tr><td>Destination IP address</td><td>" + IP._ipv4ToStr(dstIP) + "</td></tr>"; `<tr><td>Destination IP address</td><td>${IP._ipv4ToStr(dstIP)}</td></tr>`;
if (ihl > 5) { if (ihl > 5) {
output += "<tr><td>Options</td><td>" + Utils.byteArrayToHex(options) + "</td></tr>"; output += `<tr><td>Options</td><td>${Utils.byteArrayToHex(options)}</td></tr>`;
} }
return output + "</table>"; return `${output}</table>`;
}, },
@ -554,11 +554,11 @@ const IP = {
ip2 = ip1 | ~mask; ip2 = ip1 | ~mask;
if (includeNetworkInfo) { if (includeNetworkInfo) {
output += "Network: " + IP._ipv4ToStr(network) + "\n"; output += `Network: ${IP._ipv4ToStr(network)}\n`;
output += "CIDR: " + cidrRange + "\n"; output += `CIDR: ${cidrRange}\n`;
output += "Mask: " + IP._ipv4ToStr(mask) + "\n"; output += `Mask: ${IP._ipv4ToStr(mask)}\n`;
output += "Range: " + IP._ipv4ToStr(ip1) + " - " + IP._ipv4ToStr(ip2) + "\n"; output += `Range: ${IP._ipv4ToStr(ip1)} - ${IP._ipv4ToStr(ip2)}\n`;
output += "Total addresses in range: " + (((ip2 - ip1) >>> 0) + 1) + "\n\n"; output += `Total addresses in range: ${((ip2 - ip1) >>> 0) + 1}\n\n`;
} }
if (enumerateAddresses) { if (enumerateAddresses) {
@ -608,12 +608,12 @@ const IP = {
} }
if (includeNetworkInfo) { if (includeNetworkInfo) {
output += "Network: " + IP._ipv6ToStr(network) + "\n"; output += `Network: ${IP._ipv6ToStr(network)}\n`;
output += "Shorthand: " + IP._ipv6ToStr(network, true) + "\n"; output += `Shorthand: ${IP._ipv6ToStr(network, true)}\n`;
output += "CIDR: " + cidrRange + "\n"; output += `CIDR: ${cidrRange}\n`;
output += "Mask: " + IP._ipv6ToStr(mask) + "\n"; output += `Mask: ${IP._ipv6ToStr(mask)}\n`;
output += "Range: " + IP._ipv6ToStr(ip1) + " - " + IP._ipv6ToStr(ip2) + "\n"; output += `Range: ${IP._ipv6ToStr(ip1)} - ${IP._ipv6ToStr(ip2)}\n`;
output += "Total addresses in range: " + (parseInt(total.join(""), 2) + 1) + "\n\n"; output += `Total addresses in range: ${parseInt(total.join(""), 2) + 1}\n\n`;
} }
return output; return output;
@ -679,13 +679,13 @@ const IP = {
if (includeNetworkInfo) { if (includeNetworkInfo) {
output += "Minimum subnet required to hold this range:\n"; output += "Minimum subnet required to hold this range:\n";
output += "\tNetwork: " + IP._ipv4ToStr(network) + "\n"; output += `\tNetwork: ${IP._ipv4ToStr(network)}\n`;
output += "\tCIDR: " + cidr + "\n"; output += `\tCIDR: ${cidr}\n`;
output += "\tMask: " + IP._ipv4ToStr(mask) + "\n"; output += `\tMask: ${IP._ipv4ToStr(mask)}\n`;
output += "\tSubnet range: " + IP._ipv4ToStr(subIp1) + " - " + IP._ipv4ToStr(subIp2) + "\n"; output += `\tSubnet range: ${IP._ipv4ToStr(subIp1)} - ${IP._ipv4ToStr(subIp2)}\n`;
output += "\tTotal addresses in subnet: " + (((subIp2 - subIp1) >>> 0) + 1) + "\n\n"; output += `\tTotal addresses in subnet: ${((subIp2 - subIp1) >>> 0) + 1}\n\n`;
output += "Range: " + IP._ipv4ToStr(ip1) + " - " + IP._ipv4ToStr(ip2) + "\n"; output += `Range: ${IP._ipv4ToStr(ip1)} - ${IP._ipv4ToStr(ip2)}\n`;
output += "Total addresses in range: " + (((ip2 - ip1) >>> 0) + 1) + "\n\n"; output += `Total addresses in range: ${((ip2 - ip1) >>> 0) + 1}\n\n`;
} }
if (enumerateAddresses) { if (enumerateAddresses) {
@ -726,9 +726,9 @@ const IP = {
} }
if (includeNetworkInfo) { if (includeNetworkInfo) {
output += "Range: " + IP._ipv6ToStr(ip1) + " - " + IP._ipv6ToStr(ip2) + "\n"; output += `Range: ${IP._ipv6ToStr(ip1)} - ${IP._ipv6ToStr(ip2)}\n`;
output += "Shorthand range: " + IP._ipv6ToStr(ip1, true) + " - " + IP._ipv6ToStr(ip2, true) + "\n"; output += `Shorthand range: ${IP._ipv6ToStr(ip1, true)} - ${IP._ipv6ToStr(ip2, true)}\n`;
output += "Total addresses in range: " + (parseInt(total.join(""), 2) + 1) + "\n\n"; output += `Total addresses in range: ${parseInt(total.join(""), 2) + 1}\n\n`;
} }
return output; return output;
@ -793,7 +793,7 @@ const IP = {
blockC = (ipInt >> 8) & 255, blockC = (ipInt >> 8) & 255,
blockD = ipInt & 255; blockD = ipInt & 255;
return blockA + "." + blockB + "." + blockC + "." + blockD; return `${blockA}.${blockB}.${blockC}.${blockD}`;
}, },
@ -881,7 +881,7 @@ const IP = {
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if (i !== start) { if (i !== start) {
output += Utils.hex(ipv6[i], 1) + ":"; output += `${Utils.hex(ipv6[i], 1)}:`;
} else { } else {
output += ":"; output += ":";
i = end; i = end;
@ -889,10 +889,10 @@ const IP = {
} }
} }
if (output[0] === ":") if (output[0] === ":")
output = ":" + output; output = `:${output}`;
} else { } else {
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
output += Utils.hex(ipv6[i], 4) + ":"; output += `${Utils.hex(ipv6[i], 4)}:`;
} }
} }
return output.slice(0, output.length-1); return output.slice(0, output.length-1);

View file

@ -127,7 +127,7 @@ const JS = {
result = escodegen.generate(AST, options); result = escodegen.generate(AST, options);
} catch (e) { } catch (e) {
// Leave original error so the user can see the detail // Leave original error so the user can see the detail
throw "Unable to parse JavaScript.<br>" + e.message; throw `Unable to parse JavaScript.<br>${e.message}`;
} }
return result; return result;
}, },

View file

@ -17,7 +17,7 @@ const Numberwang = {
if (!input) return "Let's play Wangernumb!"; if (!input) return "Let's play Wangernumb!";
const match = input.match(/\d+/); const match = input.match(/\d+/);
if (match) { if (match) {
return match[0] + "! That's Numberwang!"; return `${match[0]}! That's Numberwang!`;
} else { } else {
// That's a bad miss! // That's a bad miss!
return "Sorry, that's not Numberwang. Let's rotate the board!"; return "Sorry, that's not Numberwang. Let's rotate the board!";

View file

@ -158,12 +158,12 @@ const OS = {
return "Invalid input format.\nPlease enter the permissions in either octal (e.g. 755) or textual (e.g. drwxr-xr-x) format."; return "Invalid input format.\nPlease enter the permissions in either octal (e.g. 755) or textual (e.g. drwxr-xr-x) format.";
} }
output += "Textual representation: " + OS._permsToStr(perms); output += `Textual representation: ${OS._permsToStr(perms)}`;
output += "\nOctal representation: " + OS._permsToOctal(perms); output += `\nOctal representation: ${OS._permsToOctal(perms)}`;
// File type // File type
if (textual) { if (textual) {
output += "\nFile type: " + OS._ftFromPerms(perms); output += `\nFile type: ${OS._ftFromPerms(perms)}`;
} }
// setuid, setgid // setuid, setgid
@ -180,14 +180,14 @@ const OS = {
} }
// Permission matrix // Permission matrix
output += "\n\n +---------+-------+-------+-------+\n" + output += `${"\n\n +---------+-------+-------+-------+\n" +
" | | User | Group | Other |\n" + " | | User | Group | Other |\n" +
" +---------+-------+-------+-------+\n" + " +---------+-------+-------+-------+\n" +
" | Read | " + (perms.ru ? "X" : " ") + " | " + (perms.rg ? "X" : " ") + " | " + (perms.ro ? "X" : " ") + " |\n" + " | Read | "}${perms.ru ? "X" : " "} | ${perms.rg ? "X" : " "} | ${perms.ro ? "X" : " "} |\n` +
" +---------+-------+-------+-------+\n" + " +---------+-------+-------+-------+\n" +
" | Write | " + (perms.wu ? "X" : " ") + " | " + (perms.wg ? "X" : " ") + " | " + (perms.wo ? "X" : " ") + " |\n" + ` | Write | ${perms.wu ? "X" : " "} | ${perms.wg ? "X" : " "} | ${perms.wo ? "X" : " "} |\n` +
" +---------+-------+-------+-------+\n" + " +---------+-------+-------+-------+\n" +
" | Execute | " + (perms.eu ? "X" : " ") + " | " + (perms.eg ? "X" : " ") + " | " + (perms.eo ? "X" : " ") + " |\n" + ` | Execute | ${perms.eu ? "X" : " "} | ${perms.eg ? "X" : " "} | ${perms.eo ? "X" : " "} |\n` +
" +---------+-------+-------+-------+\n"; " +---------+-------+-------+-------+\n";
return output; return output;

View file

@ -80,7 +80,7 @@ const PublicKey = {
}); });
pkFields.push({ pkFields.push({
key: "Length", key: "Length",
value: (((new r.BigInteger(pk.pubKeyHex, 16)).bitLength()-3) /2) + " bits" value: `${((new r.BigInteger(pk.pubKeyHex, 16)).bitLength()-3) /2} bits`
}); });
pkFields.push({ pkFields.push({
key: "pub", key: "pub",
@ -106,7 +106,7 @@ const PublicKey = {
} else if (pk.e) { // RSA } else if (pk.e) { // RSA
pkFields.push({ pkFields.push({
key: "Length", key: "Length",
value: pk.n.bitLength() + " bits" value: `${pk.n.bitLength()} bits`
}); });
pkFields.push({ pkFields.push({
key: "Modulus", key: "Modulus",
@ -114,7 +114,7 @@ const PublicKey = {
}); });
pkFields.push({ pkFields.push({
key: "Exponent", key: "Exponent",
value: pk.e + " (0x" + pk.e.toString(16) + ")" value: `${pk.e} (0x${pk.e.toString(16)})`
}); });
} else { } else {
pkFields.push({ pkFields.push({
@ -132,20 +132,20 @@ const PublicKey = {
} }
if (breakoutSig) { // DSA or ECDSA if (breakoutSig) { // DSA or ECDSA
sigStr = " r: " + PublicKey._formatByteStr(r.ASN1HEX.getDecendantHexVByNthList(certSig, 0, [0]), 16, 18) + "\n" + sigStr = ` r: ${PublicKey._formatByteStr(r.ASN1HEX.getDecendantHexVByNthList(certSig, 0, [0]), 16, 18)}\n` +
" s: " + PublicKey._formatByteStr(r.ASN1HEX.getDecendantHexVByNthList(certSig, 0, [1]), 16, 18) + "\n"; ` s: ${PublicKey._formatByteStr(r.ASN1HEX.getDecendantHexVByNthList(certSig, 0, [1]), 16, 18)}\n`;
} else { // RSA or unknown } else { // RSA or unknown
sigStr = " Signature: " + PublicKey._formatByteStr(certSig, 16, 18) + "\n"; sigStr = ` Signature: ${PublicKey._formatByteStr(certSig, 16, 18)}\n`;
} }
// Format Public Key fields // Format Public Key fields
for (let i = 0; i < pkFields.length; i++) { for (let i = 0; i < pkFields.length; i++) {
pkStr += " " + pkFields[i].key + ":" + pkStr += ` ${pkFields[i].key}:${
Utils.padLeft( Utils.padLeft(
pkFields[i].value + "\n", `${pkFields[i].value}\n`,
18 - (pkFields[i].key.length + 3) + pkFields[i].value.length + 1, 18 - (pkFields[i].key.length + 3) + pkFields[i].value.length + 1,
" " " "
); )}`;
} }
let issuerStr = PublicKey._formatDnStr(issuer, 2), let issuerStr = PublicKey._formatDnStr(issuer, 2),
@ -153,24 +153,24 @@ const PublicKey = {
naDate = PublicKey._formatDate(notAfter), naDate = PublicKey._formatDate(notAfter),
subjectStr = PublicKey._formatDnStr(subject, 2); subjectStr = PublicKey._formatDnStr(subject, 2);
const output = "Version: " + (parseInt(version, 16) + 1) + " (0x" + version + ")\n" + const output = `Version: ${parseInt(version, 16) + 1} (0x${version})\n` +
"Serial number: " + new r.BigInteger(sn, 16).toString() + " (0x" + sn + ")\n" + `Serial number: ${new r.BigInteger(sn, 16).toString()} (0x${sn})\n` +
"Algorithm ID: " + algorithm + "\n" + `Algorithm ID: ${algorithm}\n` +
"Validity\n" + "Validity\n" +
" Not Before: " + nbDate + " (dd-mm-yy hh:mm:ss) (" + notBefore + ")\n" + ` Not Before: ${nbDate} (dd-mm-yy hh:mm:ss) (${notBefore})\n` +
" Not After: " + naDate + " (dd-mm-yy hh:mm:ss) (" + notAfter + ")\n" + ` Not After: ${naDate} (dd-mm-yy hh:mm:ss) (${notAfter})\n` +
"Issuer\n" + `Issuer\n${
issuerStr + issuerStr
"Subject\n" + }Subject\n${
subjectStr + subjectStr
"Public Key\n" + }Public Key\n` +
" Algorithm: " + pkAlgorithm + "\n" + ` Algorithm: ${pkAlgorithm}\n${
pkStr + pkStr
"Certificate Signature\n" + }Certificate Signature\n` +
" Algorithm: " + certSigAlg + "\n" + ` Algorithm: ${certSigAlg}\n${
sigStr + sigStr
"\nExtensions (parsed ASN.1)\n" + }\nExtensions (parsed ASN.1)\n${
extensions; extensions}`;
return output; return output;
}, },
@ -186,11 +186,11 @@ const PublicKey = {
runPemToHex: function(input, args) { runPemToHex: function(input, args) {
if (input.indexOf("-----BEGIN") < 0) { if (input.indexOf("-----BEGIN") < 0) {
// Add header so that the KEYUTIL function works // Add header so that the KEYUTIL function works
input = "-----BEGIN CERTIFICATE-----" + input; input = `-----BEGIN CERTIFICATE-----${input}`;
} }
if (input.indexOf("-----END") < 0) { if (input.indexOf("-----END") < 0) {
// Add footer so that the KEYUTIL function works // Add footer so that the KEYUTIL function works
input = input + "-----END CERTIFICATE-----"; input = `${input}-----END CERTIFICATE-----`;
} }
return r.KEYUTIL.getHexFromPEM(input); return r.KEYUTIL.getHexFromPEM(input);
}, },
@ -290,7 +290,7 @@ const PublicKey = {
key = fields[i].split("=")[0]; key = fields[i].split("=")[0];
value = fields[i].split("=")[1]; value = fields[i].split("=")[1];
str = Utils.padRight(key, maxKeyLen) + " = " + value + "\n"; str = `${Utils.padRight(key, maxKeyLen)} = ${value}\n`;
output += Utils.padLeft(str, indent + str.length, " "); output += Utils.padLeft(str, indent + str.length, " ");
} }
@ -314,7 +314,7 @@ const PublicKey = {
let output = ""; let output = "";
for (let i = 0; i < byteStr.length; i += length) { for (let i = 0; i < byteStr.length; i += length) {
const str = byteStr.slice(i, i + length) + "\n"; const str = `${byteStr.slice(i, i + length)}\n`;
if (i === 0) { if (i === 0) {
output += str; output += str;
} else { } else {
@ -334,12 +334,12 @@ const PublicKey = {
* @returns {string} * @returns {string}
*/ */
_formatDate: function(dateStr) { _formatDate: function(dateStr) {
return dateStr[4] + dateStr[5] + "/" + return `${dateStr[4] + dateStr[5]}/${
dateStr[2] + dateStr[3] + "/" + dateStr[2]}${dateStr[3]}/${
dateStr[0] + dateStr[1] + " " + dateStr[0]}${dateStr[1]} ${
dateStr[6] + dateStr[7] + ":" + dateStr[6]}${dateStr[7]}:${
dateStr[8] + dateStr[9] + ":" + dateStr[8]}${dateStr[9]}:${
dateStr[10] + dateStr[11]; dateStr[10]}${dateStr[11]}`;
}, },
}; };
@ -359,7 +359,7 @@ r.X509.hex2dn = function(hDN) {
const a = r.ASN1HEX.getPosArrayOfChildren_AtObj(hDN, 0); const a = r.ASN1HEX.getPosArrayOfChildren_AtObj(hDN, 0);
for (let i = 0; i < a.length; i++) { for (let i = 0; i < a.length; i++) {
const hRDN = r.ASN1HEX.getHexOfTLV_AtObj(hDN, a[i]); const hRDN = r.ASN1HEX.getHexOfTLV_AtObj(hDN, a[i]);
s = s + ",/|" + r.X509.hex2rdn(hRDN); s = `${s},/|${r.X509.hex2rdn(hRDN)}`;
} }
return s; return s;
}; };

View file

@ -118,7 +118,7 @@ const QuotedPrintable = {
result += String.fromCharCode(buffer[i]); result += String.fromCharCode(buffer[i]);
continue; continue;
} }
result += "=" + (buffer[i] < 0x10 ? "0" : "") + buffer[i].toString(16).toUpperCase(); result += `=${buffer[i] < 0x10 ? "0" : ""}${buffer[i].toString(16).toUpperCase()}`;
} }
return result; return result;
@ -179,7 +179,7 @@ const QuotedPrintable = {
*/ */
_addBase64SoftLinebreaks: function(base64EncodedStr, lineLengthMax) { _addBase64SoftLinebreaks: function(base64EncodedStr, lineLengthMax) {
base64EncodedStr = (base64EncodedStr || "").toString().trim(); base64EncodedStr = (base64EncodedStr || "").toString().trim();
return base64EncodedStr.replace(new RegExp(".{" + lineLengthMax + "}", "g"), "$&\r\n").trim(); return base64EncodedStr.replace(new RegExp(`.{${lineLengthMax}}`, "g"), "$&\r\n").trim();
}, },

View file

@ -156,7 +156,7 @@ const SeqUtils = {
width = lines.length.toString().length; width = lines.length.toString().length;
for (let n = 0; n < lines.length; n++) { for (let n = 0; n < lines.length; n++) {
output += Utils.pad((n+1).toString(), width, " ") + " " + lines[n] + "\n"; output += `${Utils.pad((n+1).toString(), width, " ")} ${lines[n]}\n`;
} }
return output.slice(0, output.length-1); return output.slice(0, output.length-1);
}, },

View file

@ -127,7 +127,7 @@ const StrUtils = {
return "Error: Invalid output format"; return "Error: Invalid output format";
} }
} catch (err) { } catch (err) {
return "Invalid regex. Details: " + err.message; return `Invalid regex. Details: ${err.message}`;
} }
} else { } else {
return Utils.escapeHtml(input); return Utils.escapeHtml(input);
@ -281,7 +281,7 @@ const StrUtils = {
try { try {
regex = new RegExp(args[1]); regex = new RegExp(args[1]);
} catch (err) { } catch (err) {
return "Invalid regex. Details: " + err.message; return `Invalid regex. Details: ${err.message}`;
} }
const regexFilter = function(value) { const regexFilter = function(value) {
@ -357,9 +357,9 @@ const StrUtils = {
for (let i = 0; i < diff.length; i++) { for (let i = 0; i < diff.length; i++) {
if (diff[i].added) { if (diff[i].added) {
if (showAdded) output += "<span class='hlgreen'>" + Utils.escapeHtml(diff[i].value) + "</span>"; if (showAdded) output += `<span class='hlgreen'>${Utils.escapeHtml(diff[i].value)}</span>`;
} else if (diff[i].removed) { } else if (diff[i].removed) {
if (showRemoved) output += "<span class='hlred'>" + Utils.escapeHtml(diff[i].value) + "</span>"; if (showRemoved) output += `<span class='hlred'>${Utils.escapeHtml(diff[i].value)}</span>`;
} else { } else {
output += Utils.escapeHtml(diff[i].value); output += Utils.escapeHtml(diff[i].value);
} }
@ -422,11 +422,11 @@ const StrUtils = {
} }
if (match && !inMatch) { if (match && !inMatch) {
outputs[s] += "<span class='hlgreen'>" + Utils.escapeHtml(samples[s][i]); outputs[s] += `<span class='hlgreen'>${Utils.escapeHtml(samples[s][i])}`;
if (samples[s].length === i + 1) outputs[s] += "</span>"; if (samples[s].length === i + 1) outputs[s] += "</span>";
if (s === samples.length - 1) inMatch = true; if (s === samples.length - 1) inMatch = true;
} else if (!match && inMatch) { } else if (!match && inMatch) {
outputs[s] += "</span>" + Utils.escapeHtml(samples[s][i]); outputs[s] += `</span>${Utils.escapeHtml(samples[s][i])}`;
if (s === samples.length - 1) inMatch = false; if (s === samples.length - 1) inMatch = false;
} else { } else {
outputs[s] += Utils.escapeHtml(samples[s][i]); outputs[s] += Utils.escapeHtml(samples[s][i]);
@ -536,7 +536,7 @@ const StrUtils = {
output += Utils.escapeHtml(input.slice(i, m.index)); output += Utils.escapeHtml(input.slice(i, m.index));
// Add match with highlighting // Add match with highlighting
output += "<span class='hl"+hl+"'>" + Utils.escapeHtml(m[0]) + "</span>"; output += `<span class='hl${hl}'>${Utils.escapeHtml(m[0])}</span>`;
// Switch highlight // Switch highlight
hl = hl === 1 ? 2 : 1; hl = hl === 1 ? 2 : 1;
@ -549,7 +549,7 @@ const StrUtils = {
output += Utils.escapeHtml(input.slice(i, input.length)); output += Utils.escapeHtml(input.slice(i, input.length));
if (displayTotal) if (displayTotal)
output = "Total found: " + total + "\n\n" + output; output = `Total found: ${total}\n\n${output}`;
return output; return output;
}, },
@ -574,20 +574,20 @@ const StrUtils = {
while ((match = regex.exec(input))) { while ((match = regex.exec(input))) {
total++; total++;
if (matches) { if (matches) {
output += match[0] + "\n"; output += `${match[0]}\n`;
} }
if (captureGroups) { if (captureGroups) {
for (let i = 1; i < match.length; i++) { for (let i = 1; i < match.length; i++) {
if (matches) { if (matches) {
output += " Group " + i + ": "; output += ` Group ${i}: `;
} }
output += match[i] + "\n"; output += `${match[i]}\n`;
} }
} }
} }
if (displayTotal) if (displayTotal)
output = "Total found: " + total + "\n\n" + output; output = `Total found: ${total}\n\n${output}`;
return output; return output;
}, },

View file

@ -229,11 +229,11 @@ const Tidy = {
if (position === "Start") { if (position === "Start") {
for (i = 0; i < lines.length; i++) { for (i = 0; i < lines.length; i++) {
output += Utils.padLeft(lines[i], lines[i].length+len, chr) + "\n"; output += `${Utils.padLeft(lines[i], lines[i].length+len, chr)}\n`;
} }
} else if (position === "End") { } else if (position === "End") {
for (i = 0; i < lines.length; i++) { for (i = 0; i < lines.length; i++) {
output += Utils.padRight(lines[i], lines[i].length+len, chr) + "\n"; output += `${Utils.padRight(lines[i], lines[i].length+len, chr)}\n`;
} }
} }

View file

@ -71,9 +71,9 @@ const URL_ = {
if (a.protocol) { if (a.protocol) {
let output = ""; let output = "";
if (a.hostname !== window.location.hostname) { if (a.hostname !== window.location.hostname) {
output = "Protocol:\t" + a.protocol + "\n"; output = `Protocol:\t${a.protocol}\n`;
if (a.hostname) output += "Hostname:\t" + a.hostname + "\n"; if (a.hostname) output += `Hostname:\t${a.hostname}\n`;
if (a.port) output += "Port:\t\t" + a.port + "\n"; if (a.port) output += `Port:\t\t${a.port}\n`;
} }
if (a.pathname && a.pathname !== window.location.pathname) { if (a.pathname && a.pathname !== window.location.pathname) {
@ -81,11 +81,11 @@ const URL_ = {
if (pathname.indexOf(window.location.pathname) === 0) if (pathname.indexOf(window.location.pathname) === 0)
pathname = pathname.replace(window.location.pathname, ""); pathname = pathname.replace(window.location.pathname, "");
if (pathname) if (pathname)
output += "Path name:\t" + pathname + "\n"; output += `Path name:\t${pathname}\n`;
} }
if (a.hash && a.hash !== window.location.hash) { if (a.hash && a.hash !== window.location.hash) {
output += "Hash:\t\t" + a.hash + "\n"; output += `Hash:\t\t${a.hash}\n`;
} }
if (a.search && a.search !== window.location.search) { if (a.search && a.search !== window.location.search) {
@ -97,9 +97,9 @@ const URL_ = {
padding = (splitArgs[i][0].length > padding) ? splitArgs[i][0].length : padding; padding = (splitArgs[i][0].length > padding) ? splitArgs[i][0].length : padding;
} }
for (i = 0; i < splitArgs.length; i++) { for (i = 0; i < splitArgs.length; i++) {
output += "\t" + Utils.padRight(splitArgs[i][0], padding); output += `\t${Utils.padRight(splitArgs[i][0], padding)}`;
if (splitArgs[i].length > 1 && splitArgs[i][1].length) if (splitArgs[i].length > 1 && splitArgs[i][1].length)
output += " = " + splitArgs[i][1] + "\n"; output += ` = ${splitArgs[i][1]}\n`;
else output += "\n"; else output += "\n";
} }
} }

View file

@ -27,7 +27,7 @@ const Unicode = {
*/ */
runUnescape: function(input, args) { runUnescape: function(input, args) {
let prefix = Unicode._prefixToRegex[args[0]], let prefix = Unicode._prefixToRegex[args[0]],
regex = new RegExp(prefix+"([a-f\\d]{4,6})", "ig"), regex = new RegExp(`${prefix}([a-f\\d]{4,6})`, "ig"),
output = "", output = "",
m, m,
i = 0; i = 0;

View file

@ -136,8 +136,8 @@ App.prototype.bake = async function(step) {
// If baking took too long, disable auto-bake // If baking took too long, disable auto-bake
if (response.duration > this.options.autoBakeThreshold && this.autoBake_) { if (response.duration > this.options.autoBakeThreshold && this.autoBake_) {
this.manager.controls.setAutoBake(false); this.manager.controls.setAutoBake(false);
this.alert("Baking took longer than " + this.options.autoBakeThreshold + this.alert(`Baking took longer than ${this.options.autoBakeThreshold
"ms, Auto Bake has been disabled.", "warning", 5000); }ms, Auto Bake has been disabled.`, "warning", 5000);
} }
}; };
@ -323,8 +323,8 @@ App.prototype.validFavourites = function(favourites) {
if (this.operations.hasOwnProperty(favourites[i])) { if (this.operations.hasOwnProperty(favourites[i])) {
validFavs.push(favourites[i]); validFavs.push(favourites[i]);
} else { } else {
this.alert("The operation \"" + Utils.escapeHtml(favourites[i]) + this.alert(`The operation "${Utils.escapeHtml(favourites[i])
"\" is no longer available. It has been removed from your favourites.", "info"); }" is no longer available. It has been removed from your favourites.`, "info");
} }
} }
return validFavs; return validFavs;
@ -362,7 +362,7 @@ App.prototype.addFavourite = function(name) {
const favourites = JSON.parse(localStorage.favourites); const favourites = JSON.parse(localStorage.favourites);
if (favourites.indexOf(name) >= 0) { if (favourites.indexOf(name) >= 0) {
this.alert("'" + name + "' is already in your favourites", "info", 2000); this.alert(`'${name}' is already in your favourites`, "info", 2000);
return; return;
} }
@ -481,8 +481,8 @@ App.prototype.setRecipeConfig = function(recipeConfig) {
// toggleString // toggleString
args[j].value = recipeConfig[i].args[j].string; args[j].value = recipeConfig[i].args[j].string;
args[j].previousSibling.children[0].innerHTML = args[j].previousSibling.children[0].innerHTML =
Utils.escapeHtml(recipeConfig[i].args[j].option) + `${Utils.escapeHtml(recipeConfig[i].args[j].option)
" <span class='caret'></span>"; } <span class='caret'></span>`;
} else { } else {
// all others // all others
args[j].value = recipeConfig[i].args[j]; args[j].value = recipeConfig[i].args[j];
@ -521,11 +521,11 @@ App.prototype.setCompileMessage = function() {
// Display time since last build and compile message // Display time since last build and compile message
let now = new Date(), let now = new Date(),
timeSinceCompile = Utils.fuzzyTime(now.getTime() - window.compileTime), timeSinceCompile = Utils.fuzzyTime(now.getTime() - window.compileTime),
compileInfo = "<span style=\"font-weight: normal\">Last build: " + compileInfo = `<span style="font-weight: normal">Last build: ${
timeSinceCompile.substr(0, 1).toUpperCase() + timeSinceCompile.substr(1) + " ago"; timeSinceCompile.substr(0, 1).toUpperCase()}${timeSinceCompile.substr(1)} ago`;
if (window.compileMessage !== "") { if (window.compileMessage !== "") {
compileInfo += " - " + window.compileMessage; compileInfo += ` - ${window.compileMessage}`;
} }
compileInfo += "</span>"; compileInfo += "</span>";
@ -559,7 +559,7 @@ App.prototype.setCompileMessage = function() {
App.prototype.alert = function(str, style, timeout, silent) { App.prototype.alert = function(str, style, timeout, silent) {
const time = new Date(); const time = new Date();
console.log("[" + time.toLocaleString() + "] " + str); console.log(`[${time.toLocaleString()}] ${str}`);
if (silent) return; if (silent) return;
style = style || "danger"; style = style || "danger";
@ -572,15 +572,15 @@ App.prototype.alert = function(str, style, timeout, silent) {
alertEl.classList.remove("alert-warning"); alertEl.classList.remove("alert-warning");
alertEl.classList.remove("alert-info"); alertEl.classList.remove("alert-info");
alertEl.classList.remove("alert-success"); alertEl.classList.remove("alert-success");
alertEl.classList.add("alert-" + style); alertEl.classList.add(`alert-${style}`);
// If the box hasn't been closed, append to it rather than replacing // If the box hasn't been closed, append to it rather than replacing
if (alertEl.style.display === "block") { if (alertEl.style.display === "block") {
alertContent.innerHTML += alertContent.innerHTML +=
"<br><br>[" + time.toLocaleTimeString() + "] " + str; `<br><br>[${time.toLocaleTimeString()}] ${str}`;
} else { } else {
alertContent.innerHTML = alertContent.innerHTML =
"[" + time.toLocaleTimeString() + "] " + str; `[${time.toLocaleTimeString()}] ${str}`;
} }
// Stop the animation if it is in progress // Stop the animation if it is in progress

View file

@ -167,9 +167,9 @@ ControlsWaiter.prototype.initialiseSaveLink = function(recipeConfig) {
ControlsWaiter.prototype.generateStateUrl = function(includeRecipe, includeInput, recipeConfig, baseURL) { ControlsWaiter.prototype.generateStateUrl = function(includeRecipe, includeInput, recipeConfig, baseURL) {
recipeConfig = recipeConfig || this.app.getRecipeConfig(); recipeConfig = recipeConfig || this.app.getRecipeConfig();
const link = baseURL || window.location.protocol + "//" + const link = baseURL || `${window.location.protocol}//${
window.location.host + window.location.host
window.location.pathname; }${window.location.pathname}`;
const recipeStr = JSON.stringify(recipeConfig); const recipeStr = JSON.stringify(recipeConfig);
const inputStr = Utils.toBase64(this.app.getInput(), "A-Za-z0-9+/"); // B64 alphabet with no padding const inputStr = Utils.toBase64(this.app.getInput(), "A-Za-z0-9+/"); // B64 alphabet with no padding
@ -269,7 +269,7 @@ ControlsWaiter.prototype.saveButtonClick = function() {
localStorage.savedRecipes = JSON.stringify(savedRecipes); localStorage.savedRecipes = JSON.stringify(savedRecipes);
localStorage.recipeId = recipeId; localStorage.recipeId = recipeId;
this.app.alert("Recipe saved as \"" + recipeName + "\".", "success", 2000); this.app.alert(`Recipe saved as "${recipeName}".`, "success", 2000);
}; };
@ -355,9 +355,9 @@ ControlsWaiter.prototype.supportButtonClick = function() {
const reportBugInfo = document.getElementById("report-bug-info"); const reportBugInfo = document.getElementById("report-bug-info");
const saveLink = this.generateStateUrl(true, true, null, "https://gchq.github.io/CyberChef/"); const saveLink = this.generateStateUrl(true, true, null, "https://gchq.github.io/CyberChef/");
reportBugInfo.innerHTML = "* CyberChef compile time: " + COMPILE_TIME + "\n" + reportBugInfo.innerHTML = `* CyberChef compile time: ${COMPILE_TIME}\n` +
"* User-Agent: \n" + navigator.userAgent + "\n" + `* User-Agent: \n${navigator.userAgent}\n` +
"* [Link to reproduce](" + saveLink + ")\n\n"; `* [Link to reproduce](${saveLink})\n\n`;
}; };
export default ControlsWaiter; export default ControlsWaiter;

View file

@ -32,14 +32,14 @@ HTMLCategory.prototype.addOperation = function(operation) {
* @returns {string} * @returns {string}
*/ */
HTMLCategory.prototype.toHtml = function() { HTMLCategory.prototype.toHtml = function() {
const catName = "cat" + this.name.replace(/[\s/-:_]/g, ""); const catName = `cat${this.name.replace(/[\s/-:_]/g, "")}`;
let html = "<div class='panel category'>\ let html = `<div class='panel category'>\
<a class='category-title' data-toggle='collapse'\ <a class='category-title' data-toggle='collapse'\
data-parent='#categories' href='#" + catName + "'>\ data-parent='#categories' href='#${catName}'>\
" + this.name + "\ ${this.name}\
</a>\ </a>\
<div id='" + catName + "' class='panel-collapse collapse\ <div id='${catName}' class='panel-collapse collapse\
" + (this.selected ? " in" : "") + "'><ul class='op-list'>"; ${this.selected ? " in" : ""}'><ul class='op-list'>`;
for (let i = 0; i < this.opList.length; i++) { for (let i = 0; i < this.opList.length; i++) {
html += this.opList[i].toStubHtml(); html += this.opList[i].toStubHtml();

View file

@ -22,7 +22,7 @@ const HTMLIngredient = function(config, app, manager) {
this.placeholder = config.placeholder || false; this.placeholder = config.placeholder || false;
this.target = config.target; this.target = config.target;
this.toggleValues = config.toggleValues; this.toggleValues = config.toggleValues;
this.id = "ing-" + this.app.nextIngId(); this.id = `ing-${this.app.nextIngId()}`;
}; };
@ -40,107 +40,107 @@ HTMLIngredient.prototype.toHtml = function() {
html = inline ? "" : "<div class='clearfix'>&nbsp;</div>", html = inline ? "" : "<div class='clearfix'>&nbsp;</div>",
i, m; i, m;
html += "<div class='arg-group" + (inline ? " inline-args" : "") + html += `<div class='arg-group${inline ? " inline-args" : ""
(this.type === "text" ? " arg-group-text" : "") + "'><label class='arg-label' for='" + }${this.type === "text" ? " arg-group-text" : ""}'><label class='arg-label' for='${
this.id + "'>" + this.name + "</label>"; this.id}'>${this.name}</label>`;
switch (this.type) { switch (this.type) {
case "string": case "string":
case "binaryString": case "binaryString":
case "byteArray": case "byteArray":
html += "<input type='text' id='" + this.id + "' class='arg arg-input' arg-name='" + html += `<input type='text' id='${this.id}' class='arg arg-input' arg-name='${
this.name + "' value='" + this.value + "'" + this.name}' value='${this.value}'${
(this.disabled ? " disabled='disabled'" : "") + this.disabled ? " disabled='disabled'" : ""
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">"; }${this.placeholder ? ` placeholder='${this.placeholder}'` : ""}>`;
break; break;
case "shortString": case "shortString":
case "binaryShortString": case "binaryShortString":
html += "<input type='text' id='" + this.id + html += `<input type='text' id='${this.id
"'class='arg arg-input short-string' arg-name='" + this.name + "'value='" + }'class='arg arg-input short-string' arg-name='${this.name}'value='${
this.value + "'" + (this.disabled ? " disabled='disabled'" : "") + this.value}'${this.disabled ? " disabled='disabled'" : ""
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">"; }${this.placeholder ? ` placeholder='${this.placeholder}'` : ""}>`;
break; break;
case "toggleString": case "toggleString":
html += "<div class='input-group'><div class='input-group-btn'>\ html += `<div class='input-group'><div class='input-group-btn'>\
<button type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown'\ <button type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown'\
aria-haspopup='true' aria-expanded='false'" + aria-haspopup='true' aria-expanded='false'${
(this.disabled ? " disabled='disabled'" : "") + ">" + this.toggleValues[0] + this.disabled ? " disabled='disabled'" : ""}>${this.toggleValues[0]
" <span class='caret'></span></button><ul class='dropdown-menu'>"; } <span class='caret'></span></button><ul class='dropdown-menu'>`;
for (i = 0; i < this.toggleValues.length; i++) { for (i = 0; i < this.toggleValues.length; i++) {
html += "<li><a href='#'>" + this.toggleValues[i] + "</a></li>"; html += `<li><a href='#'>${this.toggleValues[i]}</a></li>`;
} }
html += "</ul></div><input type='text' class='arg arg-input toggle-string'" + html += `</ul></div><input type='text' class='arg arg-input toggle-string'${
(this.disabled ? " disabled='disabled'" : "") + this.disabled ? " disabled='disabled'" : ""
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + "></div>"; }${this.placeholder ? ` placeholder='${this.placeholder}'` : ""}></div>`;
break; break;
case "number": case "number":
html += "<input type='number' id='" + this.id + "'class='arg arg-input' arg-name='" + html += `<input type='number' id='${this.id}'class='arg arg-input' arg-name='${
this.name + "'value='" + this.value + "'" + this.name}'value='${this.value}'${
(this.disabled ? " disabled='disabled'" : "") + this.disabled ? " disabled='disabled'" : ""
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">"; }${this.placeholder ? ` placeholder='${this.placeholder}'` : ""}>`;
break; break;
case "boolean": case "boolean":
html += "<input type='checkbox' id='" + this.id + "'class='arg' arg-name='" + html += `<input type='checkbox' id='${this.id}'class='arg' arg-name='${
this.name + "'" + (this.value ? " checked='checked' " : "") + this.name}'${this.value ? " checked='checked' " : ""
(this.disabled ? " disabled='disabled'" : "") + ">"; }${this.disabled ? " disabled='disabled'" : ""}>`;
if (this.disableArgs) { if (this.disableArgs) {
this.manager.addDynamicListener("#" + this.id, "click", this.toggleDisableArgs, this); this.manager.addDynamicListener(`#${this.id}`, "click", this.toggleDisableArgs, this);
} }
break; break;
case "option": case "option":
html += "<select class='arg' id='" + this.id + "'arg-name='" + this.name + "'" + html += `<select class='arg' id='${this.id}'arg-name='${this.name}'${
(this.disabled ? " disabled='disabled'" : "") + ">"; this.disabled ? " disabled='disabled'" : ""}>`;
for (i = 0; i < this.value.length; i++) { for (i = 0; i < this.value.length; i++) {
if ((m = this.value[i].match(/\[([a-z0-9 -()^]+)\]/i))) { if ((m = this.value[i].match(/\[([a-z0-9 -()^]+)\]/i))) {
html += "<optgroup label='" + m[1] + "'>"; html += `<optgroup label='${m[1]}'>`;
} else if ((m = this.value[i].match(/\[\/([a-z0-9 -()^]+)\]/i))) { } else if ((m = this.value[i].match(/\[\/([a-z0-9 -()^]+)\]/i))) {
html += "</optgroup>"; html += "</optgroup>";
} else { } else {
html += "<option>" + this.value[i] + "</option>"; html += `<option>${this.value[i]}</option>`;
} }
} }
html += "</select>"; html += "</select>";
break; break;
case "populateOption": case "populateOption":
html += "<select class='arg' id='" + this.id + "'arg-name='" + this.name + "'" + html += `<select class='arg' id='${this.id}'arg-name='${this.name}'${
(this.disabled ? " disabled='disabled'" : "") + ">"; this.disabled ? " disabled='disabled'" : ""}>`;
for (i = 0; i < this.value.length; i++) { for (i = 0; i < this.value.length; i++) {
if ((m = this.value[i].name.match(/\[([a-z0-9 -()^]+)\]/i))) { if ((m = this.value[i].name.match(/\[([a-z0-9 -()^]+)\]/i))) {
html += "<optgroup label='" + m[1] + "'>"; html += `<optgroup label='${m[1]}'>`;
} else if ((m = this.value[i].name.match(/\[\/([a-z0-9 -()^]+)\]/i))) { } else if ((m = this.value[i].name.match(/\[\/([a-z0-9 -()^]+)\]/i))) {
html += "</optgroup>"; html += "</optgroup>";
} else { } else {
html += "<option populate-value='" + this.value[i].value + "'>" + html += `<option populate-value='${this.value[i].value}'>${
this.value[i].name + "</option>"; this.value[i].name}</option>`;
} }
} }
html += "</select>"; html += "</select>";
this.manager.addDynamicListener("#" + this.id, "change", this.populateOptionChange, this); this.manager.addDynamicListener(`#${this.id}`, "change", this.populateOptionChange, this);
break; break;
case "editableOption": case "editableOption":
html += "<div class='editable-option'>"; html += "<div class='editable-option'>";
html += "<select class='editable-option-select' id='sel-" + this.id + "'" + html += `<select class='editable-option-select' id='sel-${this.id}'${
(this.disabled ? " disabled='disabled'" : "") + ">"; this.disabled ? " disabled='disabled'" : ""}>`;
for (i = 0; i < this.value.length; i++) { for (i = 0; i < this.value.length; i++) {
html += "<option value='" + this.value[i].value + "'>" + this.value[i].name + "</option>"; html += `<option value='${this.value[i].value}'>${this.value[i].name}</option>`;
} }
html += "</select>"; html += "</select>";
html += "<input class='arg arg-input editable-option-input' id='" + this.id + html += `<input class='arg arg-input editable-option-input' id='${this.id
"'arg-name='" + this.name + "'" + " value='" + this.value[0].value + "'" + }'arg-name='${this.name}'` + ` value='${this.value[0].value}'${
(this.disabled ? " disabled='disabled'" : "") + this.disabled ? " disabled='disabled'" : ""
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">"; }${this.placeholder ? ` placeholder='${this.placeholder}'` : ""}>`;
html += "</div>"; html += "</div>";
this.manager.addDynamicListener("#sel-" + this.id, "change", this.editableOptionChange, this); this.manager.addDynamicListener(`#sel-${this.id}`, "change", this.editableOptionChange, this);
break; break;
case "text": case "text":
html += "<textarea id='" + this.id + "' class='arg' arg-name='" + html += `<textarea id='${this.id}' class='arg' arg-name='${
this.name + "'" + (this.disabled ? " disabled='disabled'" : "") + this.name}'${this.disabled ? " disabled='disabled'" : ""
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">" + }${this.placeholder ? ` placeholder='${this.placeholder}'` : ""}>${
this.value + "</textarea>"; this.value}</textarea>`;
break; break;
default: default:
break; break;

View file

@ -50,19 +50,19 @@ HTMLOperation.prototype.toStubHtml = function(removeIcon) {
let html = "<li class='operation'"; let html = "<li class='operation'";
if (this.description) { if (this.description) {
html += " data-container='body' data-toggle='popover' data-placement='auto right'\ html += ` data-container='body' data-toggle='popover' data-placement='auto right'\
data-content=\"" + this.description + "\" data-html='true' data-trigger='hover'"; data-content="${this.description}" data-html='true' data-trigger='hover'`;
} }
html += ">" + this.name; html += `>${this.name}`;
if (removeIcon) { if (removeIcon) {
html += "<img src='data:image/png;base64," + HTMLOperation.REMOVE_ICON + html += `<img src='data:image/png;base64,${HTMLOperation.REMOVE_ICON
"' class='op-icon remove-icon'>"; }' class='op-icon remove-icon'>`;
} }
if (this.description) { if (this.description) {
html += "<img src='data:image/png;base64," + HTMLOperation.INFO_ICON + "' class='op-icon'>"; html += `<img src='data:image/png;base64,${HTMLOperation.INFO_ICON}' class='op-icon'>`;
} }
html += "</li>"; html += "</li>";
@ -77,7 +77,7 @@ HTMLOperation.prototype.toStubHtml = function(removeIcon) {
* @returns {string} * @returns {string}
*/ */
HTMLOperation.prototype.toFullHtml = function() { HTMLOperation.prototype.toFullHtml = function() {
let html = "<div class='arg-title'>" + this.name + "</div>"; let html = `<div class='arg-title'>${this.name}</div>`;
for (let i = 0; i < this.ingList.length; i++) { for (let i = 0; i < this.ingList.length; i++) {
html += this.ingList[i].toHtml(); html += this.ingList[i].toHtml();
@ -104,15 +104,15 @@ HTMLOperation.prototype.toFullHtml = function() {
*/ */
HTMLOperation.prototype.highlightSearchString = function(searchStr, namePos, descPos) { HTMLOperation.prototype.highlightSearchString = function(searchStr, namePos, descPos) {
if (namePos >= 0) { if (namePos >= 0) {
this.name = this.name.slice(0, namePos) + "<b><u>" + this.name = `${this.name.slice(0, namePos)}<b><u>${
this.name.slice(namePos, namePos + searchStr.length) + "</u></b>" + this.name.slice(namePos, namePos + searchStr.length)}</u></b>${
this.name.slice(namePos + searchStr.length); this.name.slice(namePos + searchStr.length)}`;
} }
if (this.description && descPos >= 0) { if (this.description && descPos >= 0) {
this.description = this.description.slice(0, descPos) + "<b><u>" + this.description = `${this.description.slice(0, descPos)}<b><u>${
this.description.slice(descPos, descPos + searchStr.length) + "</u></b>" + this.description.slice(descPos, descPos + searchStr.length)}</u></b>${
this.description.slice(descPos + searchStr.length); this.description.slice(descPos + searchStr.length)}`;
} }
}; };

View file

@ -314,7 +314,7 @@ HighlighterWaiter.prototype.selectionInfo = function(start, end) {
const endStr = Utils.pad(end.toString(), width, " ").replace(/ /g, "&nbsp;"); const endStr = Utils.pad(end.toString(), width, " ").replace(/ /g, "&nbsp;");
const lenStr = Utils.pad((end-start).toString(), width, " ").replace(/ /g, "&nbsp;"); const lenStr = Utils.pad((end-start).toString(), width, " ").replace(/ /g, "&nbsp;");
return "start: " + startStr + "<br>end: " + endStr + "<br>length: " + lenStr; return `start: ${startStr}<br>end: ${endStr}<br>length: ${lenStr}`;
}; };
@ -493,16 +493,16 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
//if (colour) cssClass += "-"+colour; //if (colour) cssClass += "-"+colour;
// Remove HTML tags // Remove HTML tags
text = text.replace(/&/g, "&amp;") text = `${text.replace(/&/g, "&amp;")
.replace(/</g, "&lt;") .replace(/</g, "&lt;")
.replace(/>/g, "&gt;") .replace(/>/g, "&gt;")
.replace(/\n/g, "&#10;") .replace(/\n/g, "&#10;")
// Convert placeholders to tags // Convert placeholders to tags
.replace(startPlaceholderRegex, "<span class=\""+cssClass+"\">") .replace(startPlaceholderRegex, `<span class="${cssClass}">`)
.replace(endPlaceholderRegex, "</span>") + "&nbsp;"; .replace(endPlaceholderRegex, "</span>")}&nbsp;`;
// Adjust width to allow for scrollbars // Adjust width to allow for scrollbars
highlighter.style.width = textarea.clientWidth + "px"; highlighter.style.width = `${textarea.clientWidth}px`;
highlighter.innerHTML = text; highlighter.innerHTML = text;
highlighter.scrollTop = textarea.scrollTop; highlighter.scrollTop = textarea.scrollTop;
highlighter.scrollLeft = textarea.scrollLeft; highlighter.scrollLeft = textarea.scrollLeft;

View file

@ -72,7 +72,7 @@ InputWaiter.prototype.setInputInfo = function(length, lines) {
const lengthStr = Utils.pad(length.toString(), width, " ").replace(/ /g, "&nbsp;"); const lengthStr = Utils.pad(length.toString(), width, " ").replace(/ /g, "&nbsp;");
const linesStr = Utils.pad(lines.toString(), width, " ").replace(/ /g, "&nbsp;"); const linesStr = Utils.pad(lines.toString(), width, " ").replace(/ /g, "&nbsp;");
document.getElementById("input-info").innerHTML = "length: " + lengthStr + "<br>lines: " + linesStr; document.getElementById("input-info").innerHTML = `length: ${lengthStr}<br>lines: ${linesStr}`;
}; };
@ -178,7 +178,7 @@ InputWaiter.prototype.inputDrop = function(e) {
setInput(); setInput();
return; return;
} }
el.value = "Processing... " + Math.round(offset / file.size * 100) + "%"; el.value = `Processing... ${Math.round(offset / file.size * 100)}%`;
const slice = file.slice(offset, offset + CHUNK_SIZE); const slice = file.slice(offset, offset + CHUNK_SIZE);
reader.readAsArrayBuffer(slice); reader.readAsArrayBuffer(slice);
}; };

View file

@ -88,11 +88,11 @@ OutputWaiter.prototype.setOutputInfo = function(length, lines, duration) {
const lengthStr = Utils.pad(length.toString(), width, " ").replace(/ /g, "&nbsp;"); const lengthStr = Utils.pad(length.toString(), width, " ").replace(/ /g, "&nbsp;");
const linesStr = Utils.pad(lines.toString(), width, " ").replace(/ /g, "&nbsp;"); const linesStr = Utils.pad(lines.toString(), width, " ").replace(/ /g, "&nbsp;");
const timeStr = Utils.pad(duration.toString() + "ms", width, " ").replace(/ /g, "&nbsp;"); const timeStr = Utils.pad(`${duration.toString()}ms`, width, " ").replace(/ /g, "&nbsp;");
document.getElementById("output-info").innerHTML = "time: " + timeStr + document.getElementById("output-info").innerHTML = `time: ${timeStr
"<br>length: " + lengthStr + }<br>length: ${lengthStr
"<br>lines: " + linesStr; }<br>lines: ${linesStr}`;
document.getElementById("input-selection-info").innerHTML = ""; document.getElementById("input-selection-info").innerHTML = "";
document.getElementById("output-selection-info").innerHTML = ""; document.getElementById("output-selection-info").innerHTML = "";
}; };
@ -134,7 +134,7 @@ OutputWaiter.prototype.saveClick = function() {
if (filename) { if (filename) {
const el = document.createElement("a"); const el = document.createElement("a");
el.setAttribute("href", "data:application/octet-stream;base64;charset=utf-8," + data); el.setAttribute("href", `data:application/octet-stream;base64;charset=utf-8,${data}`);
el.setAttribute("download", filename); el.setAttribute("download", filename);
// Firefox requires that the element be added to the DOM before it can be clicked // Firefox requires that the element be added to the DOM before it can be clicked

View file

@ -406,7 +406,7 @@ RecipeWaiter.prototype.dropdownToggleClick = function(e) {
const el = e.target; const el = e.target;
const button = el.parentNode.parentNode.previousSibling; const button = el.parentNode.parentNode.previousSibling;
button.innerHTML = el.textContent + " <span class='caret'></span>"; button.innerHTML = `${el.textContent} <span class='caret'></span>`;
this.ingChange(); this.ingChange();
}; };

View file

@ -71,9 +71,9 @@ import Chef from "../src/core/Chef.js";
ret.status = "failing"; ret.status = "failing";
ret.output = [ ret.output = [
"Expected", "Expected",
"\t" + test.expectedOutput.replace(/\n/g, "\n\t"), `\t${test.expectedOutput.replace(/\n/g, "\n\t")}`,
"Received", "Received",
"\t" + result.result.replace(/\n/g, "\n\t"), `\t${result.result.replace(/\n/g, "\n\t")}`,
].join("\n"); ].join("\n");
} }
} }