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/**
build

View file

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

View file

@ -54,7 +54,7 @@ module.exports = function (grunt) {
// 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" +
"* CyberChef - The Cyber Swiss Army Knife\n" +
"*\n" +
@ -229,7 +229,7 @@ module.exports = function (grunt) {
entry: "./src/web/index.js",
output: {
filename: "scripts.js",
path: __dirname + "/build/dev"
path: `${__dirname}/build/dev`
},
plugins: [
new HtmlWebpackPlugin({
@ -245,7 +245,7 @@ module.exports = function (grunt) {
entry: "./src/web/index.js",
output: {
filename: "scripts.js",
path: __dirname + "/build/prod"
path: `${__dirname}/build/prod`
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
@ -287,7 +287,7 @@ module.exports = function (grunt) {
entry: "./test/index.js",
output: {
filename: "index.js",
path: __dirname + "/build/test"
path: `${__dirname}/build/test`
}
},
node: {
@ -295,7 +295,7 @@ module.exports = function (grunt) {
entry: "./src/node/index.js",
output: {
filename: "CyberChef.js",
path: __dirname + "/build/node",
path: `${__dirname}/build/node`,
library: "CyberChef",
libraryTarget: "commonjs2"
}
@ -307,7 +307,7 @@ module.exports = function (grunt) {
process: function (content) {
// Add Google Analytics code to index.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);
}
},

View file

@ -105,7 +105,7 @@ Dish.prototype.set = function(value, type) {
if (!this.valid()) {
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);
if (isNaN(number)) {
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;
default:

View file

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

View file

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

View file

@ -109,7 +109,7 @@ const Base58 = {
if (removeNonAlphaChars) {
return;
} 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;
if (removeNonAlphChars) {
const re = new RegExp("[^" + alphabet.replace(/[\]\\\-^]/g, "\\$&") + "]", "g");
const re = new RegExp(`[^${alphabet.replace(/[\]\\\-^]/g, "\\$&")}]`, "g");
input = input.replace(re, "");
}
@ -218,23 +218,23 @@ const Base64 = {
// Highlight offset 0
if (len0 % 4 === 2) {
staticSection = offset0.slice(0, -3);
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet).slice(0, -2)) + "'>" +
staticSection + "</span>" +
"<span class='hlgreen'>" + offset0.substr(offset0.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset0.substr(offset0.length - 2) + "</span>";
offset0 = `<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet).slice(0, -2))}'>${
staticSection}</span>` +
`<span class='hlgreen'>${offset0.substr(offset0.length - 3, 1)}</span>` +
`<span class='hlred'>${offset0.substr(offset0.length - 2)}</span>`;
} else if (len0 % 4 === 3) {
staticSection = offset0.slice(0, -2);
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet).slice(0, -1)) + "'>" +
staticSection + "</span>" +
"<span class='hlgreen'>" + offset0.substr(offset0.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset0.substr(offset0.length - 1) + "</span>";
offset0 = `<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet).slice(0, -1))}'>${
staticSection}</span>` +
`<span class='hlgreen'>${offset0.substr(offset0.length - 2, 1)}</span>` +
`<span class='hlred'>${offset0.substr(offset0.length - 1)}</span>`;
} else {
staticSection = offset0;
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet)) + "'>" +
staticSection + "</span>";
offset0 = `<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(staticSection, alphabet))}'>${
staticSection}</span>`;
}
if (!showVariable) {
@ -243,28 +243,28 @@ const Base64 = {
// Highlight offset 1
padding = "<span class='hlred'>" + offset1.substr(0, 1) + "</span>" +
"<span class='hlgreen'>" + offset1.substr(1, 1) + "</span>";
padding = `<span class='hlred'>${offset1.substr(0, 1)}</span>` +
`<span class='hlgreen'>${offset1.substr(1, 1)}</span>`;
offset1 = offset1.substr(2);
if (len1 % 4 === 2) {
staticSection = offset1.slice(0, -3);
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escapeHtml(Utils.fromBase64("AA" + staticSection, alphabet).slice(1, -2)) + "'>" +
staticSection + "</span>" +
"<span class='hlgreen'>" + offset1.substr(offset1.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset1.substr(offset1.length - 2) + "</span>";
offset1 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(`AA${staticSection}`, alphabet).slice(1, -2))}'>${
staticSection}</span>` +
`<span class='hlgreen'>${offset1.substr(offset1.length - 3, 1)}</span>` +
`<span class='hlred'>${offset1.substr(offset1.length - 2)}</span>`;
} else if (len1 % 4 === 3) {
staticSection = offset1.slice(0, -2);
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escapeHtml(Utils.fromBase64("AA" + staticSection, alphabet).slice(1, -1)) + "'>" +
staticSection + "</span>" +
"<span class='hlgreen'>" + offset1.substr(offset1.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset1.substr(offset1.length - 1) + "</span>";
offset1 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(`AA${staticSection}`, alphabet).slice(1, -1))}'>${
staticSection}</span>` +
`<span class='hlgreen'>${offset1.substr(offset1.length - 2, 1)}</span>` +
`<span class='hlred'>${offset1.substr(offset1.length - 1)}</span>`;
} else {
staticSection = offset1;
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escapeHtml(Utils.fromBase64("AA" + staticSection, alphabet).slice(1)) + "'>" +
staticSection + "</span>";
offset1 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(`AA${staticSection}`, alphabet).slice(1))}'>${
staticSection}</span>`;
}
if (!showVariable) {
@ -272,43 +272,43 @@ const Base64 = {
}
// Highlight offset 2
padding = "<span class='hlred'>" + offset2.substr(0, 2) + "</span>" +
"<span class='hlgreen'>" + offset2.substr(2, 1) + "</span>";
padding = `<span class='hlred'>${offset2.substr(0, 2)}</span>` +
`<span class='hlgreen'>${offset2.substr(2, 1)}</span>`;
offset2 = offset2.substr(3);
if (len2 % 4 === 2) {
staticSection = offset2.slice(0, -3);
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escapeHtml(Utils.fromBase64("AAA" + staticSection, alphabet).slice(2, -2)) + "'>" +
staticSection + "</span>" +
"<span class='hlgreen'>" + offset2.substr(offset2.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset2.substr(offset2.length - 2) + "</span>";
offset2 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(`AAA${staticSection}`, alphabet).slice(2, -2))}'>${
staticSection}</span>` +
`<span class='hlgreen'>${offset2.substr(offset2.length - 3, 1)}</span>` +
`<span class='hlred'>${offset2.substr(offset2.length - 2)}</span>`;
} else if (len2 % 4 === 3) {
staticSection = offset2.slice(0, -2);
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escapeHtml(Utils.fromBase64("AAA" + staticSection, alphabet).slice(2, -2)) + "'>" +
staticSection + "</span>" +
"<span class='hlgreen'>" + offset2.substr(offset2.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset2.substr(offset2.length - 1) + "</span>";
offset2 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(`AAA${staticSection}`, alphabet).slice(2, -2))}'>${
staticSection}</span>` +
`<span class='hlgreen'>${offset2.substr(offset2.length - 2, 1)}</span>` +
`<span class='hlred'>${offset2.substr(offset2.length - 1)}</span>`;
} else {
staticSection = offset2;
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escapeHtml(Utils.fromBase64("AAA" + staticSection, alphabet).slice(2)) + "'>" +
staticSection + "</span>";
offset2 = `${padding}<span data-toggle='tooltip' data-placement='top' title='${
Utils.escapeHtml(Utils.fromBase64(`AAA${staticSection}`, alphabet).slice(2))}'>${
staticSection}</span>`;
}
if (!showVariable) {
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." +
"\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" +
"\nOffset 0: " + offset0 +
"\nOffset 1: " + offset1 +
"\nOffset 2: " + offset2 +
script :
offset0 + "\n" + offset1 + "\n" + offset2);
"\nOffset 0: "}${offset0
}\nOffset 1: ${offset1
}\nOffset 2: ${offset2
}${script}` :
`${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);
resultUtf8 = Utils.byteArrayToUtf8(result);
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)
output += Utils.byteArrayToHex(result) + "\n";
output += `${Utils.byteArrayToHex(result)}\n`;
else
output += Utils.printable(resultUtf8, false) + "\n";
output += `${Utils.printable(resultUtf8, false)}\n`;
if (printKey) output += "\n";
}
return output;

View file

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

View file

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

View file

@ -39,7 +39,7 @@ const Code = {
runSyntaxHighlight: function(input, args) {
let language = args[0],
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) {
preservedTokens[t] = match[0];
return str.substring(0, match.index) +
"###preservedToken" + t + "###" +
str.substring(match.index + match[0].length);
return `${str.substring(0, match.index)
}###preservedToken${t}###${
str.substring(match.index + match[0].length)}`;
}
},
@ -344,7 +344,7 @@ const Code = {
try {
nodes = xpath.select(query, doc);
} catch (err) {
return "Invalid XPath. Details:\n" + err.message;
return `Invalid XPath. Details:\n${err.message}`;
}
const nodeToString = function(node) {
@ -396,7 +396,7 @@ const Code = {
try {
result = html.querySelectorAll(query);
} catch (err) {
return "Invalid CSS Selector. Details:\n" + err.message;
return `Invalid CSS Selector. Details:\n${err.message}`;
}
const nodeToString = function(node) {
@ -406,7 +406,7 @@ const Code = {
case Node.COMMENT_NODE: return node.data;
case Node.TEXT_NODE: return node.wholeText;
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)") {
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)") {
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)") {
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)") {
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 {
throw "Unrecognised unit";
}
@ -146,7 +146,7 @@ const DateTime = {
date = moment.tz(input, inputFormat, inputTimezone);
if (!date || date.format() === "Invalid date") throw Error;
} catch (err) {
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
return `Invalid format.\n\n${DateTime.FORMAT_EXAMPLES}`;
}
return date.tz(outputTimezone).format(outputFormat);
@ -170,20 +170,20 @@ const DateTime = {
date = moment.tz(input, inputFormat, inputTimezone);
if (!date || date.format() === "Invalid date") throw Error;
} 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") +
"\nTime: " + date.format("HH:mm:ss") +
"\nPeriod: " + date.format("A") +
"\nTimezone: " + date.format("z") +
"\nUTC offset: " + date.format("ZZ") +
"\n\nDaylight Saving Time: " + date.isDST() +
"\nLeap year: " + date.isLeapYear() +
"\nDays in this month: " + date.daysInMonth() +
"\n\nDay of year: " + date.dayOfYear() +
"\nWeek number: " + date.weekYear() +
"\nQuarter: " + date.quarter();
output += `Date: ${date.format("dddd Do MMMM YYYY")
}\nTime: ${date.format("HH:mm:ss")
}\nPeriod: ${date.format("A")
}\nTimezone: ${date.format("z")
}\nUTC offset: ${date.format("ZZ")
}\n\nDaylight Saving Time: ${date.isDST()
}\nLeap year: ${date.isLeapYear()
}\nDays in this month: ${date.daysInMonth()
}\n\nDay of year: ${date.dayOfYear()
}\nWeek number: ${date.weekYear()
}\nQuarter: ${date.quarter()}`;
return output;
},

View file

@ -30,16 +30,16 @@ const Entropy = {
output = "",
entropy = Entropy._calcEntropy(input);
output += "Shannon entropy: " + entropy + "\n" +
output += `Shannon entropy: ${entropy}\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" +
"- 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" +
"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'),\
parentRect = canvas.parentNode.getBoundingClientRect(),\
entropy = " + entropy + ",\
entropy = ${entropy},\
height = parentRect.height * 0.25;\
\
canvas.width = parentRect.width * 0.95;\
@ -56,13 +56,13 @@ const Entropy = {
max: 8\
}\
]);\
</script>";
</script>`;
let chunkEntropy = 0;
if (chunkSize !== 0) {
for (let i = 0; i < input.length; 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 {
output += "Chunk size cannot be 0.";
@ -107,27 +107,27 @@ const Entropy = {
}
// Print
let output = "<canvas id='chart-area'></canvas><br>" +
"Total data length: " + len +
"\nNumber of bytes represented: " + repr +
"\nNumber of bytes not represented: " + (256-repr) +
"\n\nByte Percentage\n" +
"<script>\
let output = `${"<canvas id='chart-area'></canvas><br>" +
"Total data length: "}${len
}\nNumber of bytes represented: ${repr
}\nNumber of bytes not represented: ${256-repr
}\n\nByte Percentage\n` +
`<script>\
var canvas = document.getElementById('chart-area'),\
parentRect = canvas.parentNode.getBoundingClientRect(),\
scores = " + JSON.stringify(percentages) + ";\
scores = ${JSON.stringify(percentages)};\
\
canvas.width = parentRect.width * 0.95;\
canvas.height = parentRect.height * 0.9;\
\
CanvasComponents.drawBarChart(canvas, scores, 'Byte', 'Frequency %', 16, 6);\
</script>";
</script>`;
for (i = 0; i < 256; i++) {
if (distrib[i] || showZeroes) {
output += " " + Utils.hex(i, 2) + " (" +
Utils.padRight(percentages[i].toFixed(2).replace(".00", "") + "%)", 8) +
Array(Math.ceil(percentages[i])+1).join("|") + "\n";
output += ` ${Utils.hex(i, 2)} (${
Utils.padRight(`${percentages[i].toFixed(2).replace(".00", "")}%)`, 8)
}${Array(Math.ceil(percentages[i])+1).join("|")}\n`;
}
}

View file

@ -29,11 +29,11 @@ const Extract = {
if (removeRegex && removeRegex.test(match[0]))
continue;
total++;
output += match[0] + "\n";
output += `${match[0]}\n`;
}
if (includeTotal)
output = "Total found: " + total + "\n\n" + output;
output = `Total found: ${total}\n\n${output}`;
return output;
},
@ -61,7 +61,7 @@ const Extract = {
let minLen = args[0] || Extract.MIN_STRING_LEN,
displayTotal = args[1],
strings = "[A-Z\\d/\\-:.,_$%'\"()<>= !\\[\\]{}@]",
regex = new RegExp(strings + "{" + minLen + ",}", "ig");
regex = new RegExp(`${strings}{${minLen},}`, "ig");
return Extract._search(input, regex, null, displayTotal);
},
@ -100,7 +100,7 @@ const Extract = {
ips = "";
if (includeIpv4 && includeIpv6) {
ips = ipv4 + "|" + ipv6;
ips = `${ipv4}|${ipv6}`;
} else if (includeIpv4) {
ips = ipv4;
} else if (includeIpv6) {
@ -115,8 +115,8 @@ const Extract = {
oneninetwo = "192\\.168\\..+",
oneseventwo = "172\\.(?:1[6-9]|2\\d|3[01])\\..+",
onetwoseven = "127\\..+",
removeRegex = new RegExp("^(?:" + ten + "|" + oneninetwo +
"|" + oneseventwo + "|" + onetwoseven + ")");
removeRegex = new RegExp(`^(?:${ten}|${oneninetwo
}|${oneseventwo}|${onetwoseven})`);
return Extract._search(input, regex, removeRegex, displayTotal);
} else {
@ -173,8 +173,8 @@ const Extract = {
path = "/[^.!,?;\"'<>()\\[\\]{}\\s\\x7F-\\xFF]*";
path += "(?:[.!,?]+[^.!,?;\"'<>()\\[\\]{}\\s\\x7F-\\xFF]+)*";
const regex = new RegExp(protocol + hostname + "(?:" + port +
")?(?:" + path + ")?", "ig");
const regex = new RegExp(`${protocol + hostname}(?:${port
})?(?:${path})?`, "ig");
return Extract._search(input, regex, null, displayTotal);
},
@ -191,7 +191,7 @@ const Extract = {
protocol = "https?://",
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)+",
regex = new RegExp("(?:" + protocol + ")?" + hostname + tld, "ig");
regex = new RegExp(`(?:${protocol})?${hostname}${tld}`, "ig");
return Extract._search(input, regex, null, displayTotal);
},
@ -222,13 +222,13 @@ const Extract = {
winDrive = "[A-Z]:\\\\",
winName = "[A-Z\\d][A-Z\\d\\- '_\\(\\)]{0,61}",
winExt = "[A-Z\\d]{1,6}",
winPath = winDrive + "(?:" + winName + "\\\\?)*" + winName +
"(?:\\." + winExt + ")?",
winPath = `${winDrive}(?:${winName}\\\\?)*${winName
}(?:\\.${winExt})?`,
unixPath = "(?:/[A-Z\\d.][A-Z\\d\\-.]{0,61})+",
filePaths = "";
if (includeWinPath && includeUnixPath) {
filePaths = winPath + "|" + unixPath;
filePaths = `${winPath}|${unixPath}`;
} else if (includeWinPath) {
filePaths = winPath;
} 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
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
regex = new RegExp(date1 + "|" + date2 + "|" + date3, "ig");
regex = new RegExp(`${date1}|${date2}|${date3}`, "ig");
return Extract._search(input, regex, null, displayTotal);
},

View file

@ -25,11 +25,11 @@ const FileType = {
if (!type) {
return "Unknown file type. Have you tried checking the entropy of this data to determine whether it might be encrypted or compressed?";
} else {
let output = "File extension: " + type.ext + "\n" +
"MIME type: " + type.mime;
let output = `File extension: ${type.ext}\n` +
`MIME type: ${type.mime}`;
if (type.desc && type.desc.length) {
output += "\nDescription: " + type.desc;
output += `\nDescription: ${type.desc}`;
}
return output;
@ -66,12 +66,12 @@ const FileType = {
continue;
}
numFound++;
output += "\nOffset " + i + " (0x" + Utils.hex(i) + "):\n" +
" File extension: " + type.ext + "\n" +
" MIME type: " + type.mime + "\n";
output += `\nOffset ${i} (0x${Utils.hex(i)}):\n` +
` File extension: ${type.ext}\n` +
` MIME type: ${type.mime}\n`;
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) {
output += "\n\n" + numCommonFound;
output += `\n\n${numCommonFound}`;
output += numCommonFound === 1 ?
" 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.";

View file

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

View file

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

View file

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

View file

@ -46,7 +46,7 @@ const Hexdump = {
const buff = input.slice(i, i+length);
let hexa = "";
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);
@ -56,12 +56,12 @@ const Hexdump = {
lineNo = lineNo.toUpperCase();
}
output += lineNo + " " +
Utils.padRight(hexa, (length*(padding+1))) +
" |" + Utils.padRight(Utils.printable(Utils.byteArrayToChars(buff)), buff.length) + "|\n";
output += `${lineNo} ${
Utils.padRight(hexa, (length*(padding+1)))
} |${Utils.padRight(Utils.printable(Utils.byteArrayToChars(buff)), buff.length)}|\n`;
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),
shorthand = IP._ipv6ToStr(ipv6, true);
output += "Longhand: " + longhand + "\nShorthand: " + shorthand + "\n";
output += `Longhand: ${longhand}\nShorthand: ${shorthand}\n`;
// Detect reserved addresses
if (shorthand === "::") {
@ -105,13 +105,13 @@ const IP = {
ipv6[3] === 0 && ipv6[4] === 0 && ipv6[5] === 0xffff) {
// 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";
} else if (ipv6[0] === 0 && ipv6[1] === 0 && ipv6[2] === 0 &&
ipv6[3] === 0 && ipv6[4] === 0xffff && ipv6[5] === 0) {
// IPv4-translated address
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";
} else if (ipv6[0] === 0x100) {
// Discard prefix per RFC 6666
@ -121,7 +121,7 @@ const IP = {
ipv6[3] === 0 && ipv6[4] === 0 && ipv6[5] === 0) {
// IPv4/IPv6 translation per RFC 6052
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";
} else if (ipv6[0] === 0x2001 && ipv6[1] === 0) {
// Teredo tunneling
@ -135,11 +135,11 @@ const IP = {
flagUg = (ipv6[4] >>> 8) & 3,
flagRandom2 = ipv6[4] & 255;
output += "\nServer IPv4 address: " + IP._ipv4ToStr(serverIpv4) +
"\nClient IPv4 address: " + IP._ipv4ToStr(clientIpv4) +
"\nClient UDP port: " + udpPort +
"\nFlags:" +
"\n\tCone: " + flagCone;
output += `\nServer IPv4 address: ${IP._ipv4ToStr(serverIpv4)
}\nClient IPv4 address: ${IP._ipv4ToStr(clientIpv4)
}\nClient UDP port: ${udpPort
}\nFlags:` +
`\n\tCone: ${flagCone}`;
if (flagCone) {
output += " (Client is behind a cone NAT)";
@ -147,20 +147,20 @@ const IP = {
output += " (Client is not behind a cone NAT)";
}
output += "\n\tR: " + flagR;
output += `\n\tR: ${flagR}`;
if (flagR) {
output += " Error: This flag should be set to 0. See RFC 5991 and RFC 4380.";
}
output += "\n\tRandom1: " + Utils.bin(flagRandom1, 4) +
"\n\tUG: " + Utils.bin(flagUg, 2);
output += `\n\tRandom1: ${Utils.bin(flagRandom1, 4)
}\n\tUG: ${Utils.bin(flagUg, 2)}`;
if (flagUg) {
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) {
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),
interfaceId = new BigInteger(interfaceIdStr, 16);
output += "\n\nEncapsulated IPv4 address: " + v4Addr +
"\nSLA ID: " + slaId +
"\nInterface ID (base 16): " + interfaceIdStr +
"\nInterface ID (base 10): " + interfaceId.toString();
output += `\n\nEncapsulated IPv4 address: ${v4Addr
}\nSLA ID: ${slaId
}\nInterface ID (base 16): ${interfaceIdStr
}\nInterface ID (base 10): ${interfaceId.toString()}`;
} else if (ipv6[0] >= 0xfc00 && ipv6[0] <= 0xfdff) {
// 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.";
@ -218,15 +218,15 @@ const IP = {
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.";
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[6] >>> 8) + ":" + Utils.hex(ipv6[6] & 0xff) + ":" +
Utils.hex(ipv6[7] >>> 8) + ":" + Utils.hex(ipv6[7] & 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[7] >>> 8) + ":" + Utils.hex(ipv6[7] & 0xff);
output += "\nInterface identifier: " + intIdent +
"\nMAC address: " + mac;
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[6] >>> 8)}:${Utils.hex(ipv6[6] & 0xff)}:${
Utils.hex(ipv6[7] >>> 8)}:${Utils.hex(ipv6[7] & 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[7] >>> 8)}:${Utils.hex(ipv6[7] & 0xff)}`;
output += `\nInterface identifier: ${intIdent
}\nMAC address: ${mac}`;
}
} else {
return "Invalid IPv6 address";
@ -263,7 +263,7 @@ const IP = {
let decimal;
if (inFormat === outFormat) {
output += lines[i] + "\n";
output += `${lines[i]}\n`;
continue;
}
@ -298,20 +298,20 @@ const IP = {
case "Dotted Decimal":
ddIp = "";
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;
case "Decimal":
decIp = ((baIp[0] << 24) | (baIp[1] << 16) | (baIp[2] << 8) | baIp[3]) >>> 0;
output += decIp.toString() + "\n";
output += `${decIp.toString()}\n`;
break;
case "Hex":
hexIp = "";
for (j = 0; j < baIp.length; j++) {
hexIp += Utils.hex(baIp[j]);
}
output += hexIp + "\n";
output += `${hexIp}\n`;
break;
default:
throw "Unsupported output IP format";
@ -399,11 +399,11 @@ const IP = {
for (network in ipv4Networks) {
ipv4Networks[network] = ipv4Networks[network].sort();
output += IP._ipv4ToStr(network) + "/" + cidr + "\n";
output += `${IP._ipv4ToStr(network)}/${cidr}\n`;
if (!onlySubnets) {
for (i = 0; i < ipv4Networks[network].length; i++) {
output += " " + IP._ipv4ToStr(ipv4Networks[network][i]) + "\n";
output += ` ${IP._ipv4ToStr(ipv4Networks[network][i])}\n`;
}
output += "\n";
}
@ -413,11 +413,11 @@ const IP = {
for (networkStr in ipv6Networks) {
//ipv6Networks[networkStr] = ipv6Networks[networkStr].sort(); TODO
output += networkStr + "/" + cidr + "\n";
output += `${networkStr}/${cidr}\n`;
if (!onlySubnets) {
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";
}
@ -470,12 +470,12 @@ const IP = {
// Version
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
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) {
// sort out options...
const optionsLen = ihl * 4 - 20;
@ -490,36 +490,36 @@ const IP = {
givenChecksum = Utils.hex(checksum),
checksumResult;
if (correctChecksum === givenChecksum) {
checksumResult = givenChecksum + " (correct)";
checksumResult = `${givenChecksum} (correct)`;
} 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>" +
"<tr><td>Version</td><td>" + version + "</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>Explicit Congestion Notification (ECN)</td><td>" + ecn + "</td></tr>" +
"<tr><td>Total length</td><td>" + length + " bytes" +
"\n IP header: " + (ihl * 4) + " bytes" +
"\n Data: " + (length - ihl * 4) + " bytes</td></tr>" +
"<tr><td>Identification</td><td>0x" + Utils.hex(identification) + " (" + identification + ")</td></tr>" +
"<tr><td>Flags</td><td>0x" + Utils.hex(flags, 2) +
"\n Reserved bit:" + (flags >> 2) + " (must be 0)" +
"\n Don't fragment:" + (flags >> 1 & 1) +
"\n More fragments:" + (flags & 1) + "</td></tr>" +
"<tr><td>Fragment offset</td><td>" + fragOffset + "</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>Header checksum</td><td>" + checksumResult + "</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>";
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>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>Explicit Congestion Notification (ECN)</td><td>${ecn}</td></tr>` +
`<tr><td>Total length</td><td>${length} bytes` +
`\n IP header: ${ihl * 4} bytes` +
`\n Data: ${length - ihl * 4} bytes</td></tr>` +
`<tr><td>Identification</td><td>0x${Utils.hex(identification)} (${identification})</td></tr>` +
`<tr><td>Flags</td><td>0x${Utils.hex(flags, 2)
}\n Reserved bit:${flags >> 2} (must be 0)` +
`\n Don't fragment:${flags >> 1 & 1
}\n More fragments:${flags & 1}</td></tr>` +
`<tr><td>Fragment offset</td><td>${fragOffset}</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>Header checksum</td><td>${checksumResult}</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>`;
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;
if (includeNetworkInfo) {
output += "Network: " + IP._ipv4ToStr(network) + "\n";
output += "CIDR: " + cidrRange + "\n";
output += "Mask: " + IP._ipv4ToStr(mask) + "\n";
output += "Range: " + IP._ipv4ToStr(ip1) + " - " + IP._ipv4ToStr(ip2) + "\n";
output += "Total addresses in range: " + (((ip2 - ip1) >>> 0) + 1) + "\n\n";
output += `Network: ${IP._ipv4ToStr(network)}\n`;
output += `CIDR: ${cidrRange}\n`;
output += `Mask: ${IP._ipv4ToStr(mask)}\n`;
output += `Range: ${IP._ipv4ToStr(ip1)} - ${IP._ipv4ToStr(ip2)}\n`;
output += `Total addresses in range: ${((ip2 - ip1) >>> 0) + 1}\n\n`;
}
if (enumerateAddresses) {
@ -608,12 +608,12 @@ const IP = {
}
if (includeNetworkInfo) {
output += "Network: " + IP._ipv6ToStr(network) + "\n";
output += "Shorthand: " + IP._ipv6ToStr(network, true) + "\n";
output += "CIDR: " + cidrRange + "\n";
output += "Mask: " + IP._ipv6ToStr(mask) + "\n";
output += "Range: " + IP._ipv6ToStr(ip1) + " - " + IP._ipv6ToStr(ip2) + "\n";
output += "Total addresses in range: " + (parseInt(total.join(""), 2) + 1) + "\n\n";
output += `Network: ${IP._ipv6ToStr(network)}\n`;
output += `Shorthand: ${IP._ipv6ToStr(network, true)}\n`;
output += `CIDR: ${cidrRange}\n`;
output += `Mask: ${IP._ipv6ToStr(mask)}\n`;
output += `Range: ${IP._ipv6ToStr(ip1)} - ${IP._ipv6ToStr(ip2)}\n`;
output += `Total addresses in range: ${parseInt(total.join(""), 2) + 1}\n\n`;
}
return output;
@ -679,13 +679,13 @@ const IP = {
if (includeNetworkInfo) {
output += "Minimum subnet required to hold this range:\n";
output += "\tNetwork: " + IP._ipv4ToStr(network) + "\n";
output += "\tCIDR: " + cidr + "\n";
output += "\tMask: " + IP._ipv4ToStr(mask) + "\n";
output += "\tSubnet range: " + IP._ipv4ToStr(subIp1) + " - " + IP._ipv4ToStr(subIp2) + "\n";
output += "\tTotal addresses in subnet: " + (((subIp2 - subIp1) >>> 0) + 1) + "\n\n";
output += "Range: " + IP._ipv4ToStr(ip1) + " - " + IP._ipv4ToStr(ip2) + "\n";
output += "Total addresses in range: " + (((ip2 - ip1) >>> 0) + 1) + "\n\n";
output += `\tNetwork: ${IP._ipv4ToStr(network)}\n`;
output += `\tCIDR: ${cidr}\n`;
output += `\tMask: ${IP._ipv4ToStr(mask)}\n`;
output += `\tSubnet range: ${IP._ipv4ToStr(subIp1)} - ${IP._ipv4ToStr(subIp2)}\n`;
output += `\tTotal addresses in subnet: ${((subIp2 - subIp1) >>> 0) + 1}\n\n`;
output += `Range: ${IP._ipv4ToStr(ip1)} - ${IP._ipv4ToStr(ip2)}\n`;
output += `Total addresses in range: ${((ip2 - ip1) >>> 0) + 1}\n\n`;
}
if (enumerateAddresses) {
@ -726,9 +726,9 @@ const IP = {
}
if (includeNetworkInfo) {
output += "Range: " + IP._ipv6ToStr(ip1) + " - " + IP._ipv6ToStr(ip2) + "\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 += `Range: ${IP._ipv6ToStr(ip1)} - ${IP._ipv6ToStr(ip2)}\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`;
}
return output;
@ -793,7 +793,7 @@ const IP = {
blockC = (ipInt >> 8) & 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++) {
if (i !== start) {
output += Utils.hex(ipv6[i], 1) + ":";
output += `${Utils.hex(ipv6[i], 1)}:`;
} else {
output += ":";
i = end;
@ -889,10 +889,10 @@ const IP = {
}
}
if (output[0] === ":")
output = ":" + output;
output = `:${output}`;
} else {
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);

View file

@ -127,7 +127,7 @@ const JS = {
result = escodegen.generate(AST, options);
} catch (e) {
// 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;
},

View file

@ -17,7 +17,7 @@ const Numberwang = {
if (!input) return "Let's play Wangernumb!";
const match = input.match(/\d+/);
if (match) {
return match[0] + "! That's Numberwang!";
return `${match[0]}! That's Numberwang!`;
} else {
// That's a bad miss!
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.";
}
output += "Textual representation: " + OS._permsToStr(perms);
output += "\nOctal representation: " + OS._permsToOctal(perms);
output += `Textual representation: ${OS._permsToStr(perms)}`;
output += `\nOctal representation: ${OS._permsToOctal(perms)}`;
// File type
if (textual) {
output += "\nFile type: " + OS._ftFromPerms(perms);
output += `\nFile type: ${OS._ftFromPerms(perms)}`;
}
// setuid, setgid
@ -180,14 +180,14 @@ const OS = {
}
// Permission matrix
output += "\n\n +---------+-------+-------+-------+\n" +
output += `${"\n\n +---------+-------+-------+-------+\n" +
" | | User | Group | Other |\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" +
" | Write | " + (perms.wu ? "X" : " ") + " | " + (perms.wg ? "X" : " ") + " | " + (perms.wo ? "X" : " ") + " |\n" +
` | Write | ${perms.wu ? "X" : " "} | ${perms.wg ? "X" : " "} | ${perms.wo ? "X" : " "} |\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";
return output;

View file

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

View file

@ -118,7 +118,7 @@ const QuotedPrintable = {
result += String.fromCharCode(buffer[i]);
continue;
}
result += "=" + (buffer[i] < 0x10 ? "0" : "") + buffer[i].toString(16).toUpperCase();
result += `=${buffer[i] < 0x10 ? "0" : ""}${buffer[i].toString(16).toUpperCase()}`;
}
return result;
@ -179,7 +179,7 @@ const QuotedPrintable = {
*/
_addBase64SoftLinebreaks: function(base64EncodedStr, lineLengthMax) {
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;
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);
},

View file

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

View file

@ -229,11 +229,11 @@ const Tidy = {
if (position === "Start") {
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") {
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) {
let output = "";
if (a.hostname !== window.location.hostname) {
output = "Protocol:\t" + a.protocol + "\n";
if (a.hostname) output += "Hostname:\t" + a.hostname + "\n";
if (a.port) output += "Port:\t\t" + a.port + "\n";
output = `Protocol:\t${a.protocol}\n`;
if (a.hostname) output += `Hostname:\t${a.hostname}\n`;
if (a.port) output += `Port:\t\t${a.port}\n`;
}
if (a.pathname && a.pathname !== window.location.pathname) {
@ -81,11 +81,11 @@ const URL_ = {
if (pathname.indexOf(window.location.pathname) === 0)
pathname = pathname.replace(window.location.pathname, "");
if (pathname)
output += "Path name:\t" + pathname + "\n";
output += `Path name:\t${pathname}\n`;
}
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) {
@ -97,9 +97,9 @@ const URL_ = {
padding = (splitArgs[i][0].length > padding) ? splitArgs[i][0].length : padding;
}
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)
output += " = " + splitArgs[i][1] + "\n";
output += ` = ${splitArgs[i][1]}\n`;
else output += "\n";
}
}

View file

@ -27,7 +27,7 @@ const Unicode = {
*/
runUnescape: function(input, args) {
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 = "",
m,
i = 0;

View file

@ -136,8 +136,8 @@ App.prototype.bake = async function(step) {
// If baking took too long, disable auto-bake
if (response.duration > this.options.autoBakeThreshold && this.autoBake_) {
this.manager.controls.setAutoBake(false);
this.alert("Baking took longer than " + this.options.autoBakeThreshold +
"ms, Auto Bake has been disabled.", "warning", 5000);
this.alert(`Baking took longer than ${this.options.autoBakeThreshold
}ms, Auto Bake has been disabled.`, "warning", 5000);
}
};
@ -323,8 +323,8 @@ App.prototype.validFavourites = function(favourites) {
if (this.operations.hasOwnProperty(favourites[i])) {
validFavs.push(favourites[i]);
} else {
this.alert("The operation \"" + Utils.escapeHtml(favourites[i]) +
"\" is no longer available. It has been removed from your favourites.", "info");
this.alert(`The operation "${Utils.escapeHtml(favourites[i])
}" is no longer available. It has been removed from your favourites.`, "info");
}
}
return validFavs;
@ -362,7 +362,7 @@ App.prototype.addFavourite = function(name) {
const favourites = JSON.parse(localStorage.favourites);
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;
}
@ -481,8 +481,8 @@ App.prototype.setRecipeConfig = function(recipeConfig) {
// toggleString
args[j].value = recipeConfig[i].args[j].string;
args[j].previousSibling.children[0].innerHTML =
Utils.escapeHtml(recipeConfig[i].args[j].option) +
" <span class='caret'></span>";
`${Utils.escapeHtml(recipeConfig[i].args[j].option)
} <span class='caret'></span>`;
} else {
// all others
args[j].value = recipeConfig[i].args[j];
@ -521,11 +521,11 @@ App.prototype.setCompileMessage = function() {
// Display time since last build and compile message
let now = new Date(),
timeSinceCompile = Utils.fuzzyTime(now.getTime() - window.compileTime),
compileInfo = "<span style=\"font-weight: normal\">Last build: " +
timeSinceCompile.substr(0, 1).toUpperCase() + timeSinceCompile.substr(1) + " ago";
compileInfo = `<span style="font-weight: normal">Last build: ${
timeSinceCompile.substr(0, 1).toUpperCase()}${timeSinceCompile.substr(1)} ago`;
if (window.compileMessage !== "") {
compileInfo += " - " + window.compileMessage;
compileInfo += ` - ${window.compileMessage}`;
}
compileInfo += "</span>";
@ -559,7 +559,7 @@ App.prototype.setCompileMessage = function() {
App.prototype.alert = function(str, style, timeout, silent) {
const time = new Date();
console.log("[" + time.toLocaleString() + "] " + str);
console.log(`[${time.toLocaleString()}] ${str}`);
if (silent) return;
style = style || "danger";
@ -572,15 +572,15 @@ App.prototype.alert = function(str, style, timeout, silent) {
alertEl.classList.remove("alert-warning");
alertEl.classList.remove("alert-info");
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 (alertEl.style.display === "block") {
alertContent.innerHTML +=
"<br><br>[" + time.toLocaleTimeString() + "] " + str;
`<br><br>[${time.toLocaleTimeString()}] ${str}`;
} else {
alertContent.innerHTML =
"[" + time.toLocaleTimeString() + "] " + str;
`[${time.toLocaleTimeString()}] ${str}`;
}
// 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) {
recipeConfig = recipeConfig || this.app.getRecipeConfig();
const link = baseURL || window.location.protocol + "//" +
window.location.host +
window.location.pathname;
const link = baseURL || `${window.location.protocol}//${
window.location.host
}${window.location.pathname}`;
const recipeStr = JSON.stringify(recipeConfig);
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.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 saveLink = this.generateStateUrl(true, true, null, "https://gchq.github.io/CyberChef/");
reportBugInfo.innerHTML = "* CyberChef compile time: " + COMPILE_TIME + "\n" +
"* User-Agent: \n" + navigator.userAgent + "\n" +
"* [Link to reproduce](" + saveLink + ")\n\n";
reportBugInfo.innerHTML = `* CyberChef compile time: ${COMPILE_TIME}\n` +
`* User-Agent: \n${navigator.userAgent}\n` +
`* [Link to reproduce](${saveLink})\n\n`;
};
export default ControlsWaiter;

View file

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

View file

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

View file

@ -50,19 +50,19 @@ HTMLOperation.prototype.toStubHtml = function(removeIcon) {
let html = "<li class='operation'";
if (this.description) {
html += " data-container='body' data-toggle='popover' data-placement='auto right'\
data-content=\"" + this.description + "\" data-html='true' data-trigger='hover'";
html += ` data-container='body' data-toggle='popover' data-placement='auto right'\
data-content="${this.description}" data-html='true' data-trigger='hover'`;
}
html += ">" + this.name;
html += `>${this.name}`;
if (removeIcon) {
html += "<img src='data:image/png;base64," + HTMLOperation.REMOVE_ICON +
"' class='op-icon remove-icon'>";
html += `<img src='data:image/png;base64,${HTMLOperation.REMOVE_ICON
}' class='op-icon remove-icon'>`;
}
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>";
@ -77,7 +77,7 @@ HTMLOperation.prototype.toStubHtml = function(removeIcon) {
* @returns {string}
*/
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++) {
html += this.ingList[i].toHtml();
@ -104,15 +104,15 @@ HTMLOperation.prototype.toFullHtml = function() {
*/
HTMLOperation.prototype.highlightSearchString = function(searchStr, namePos, descPos) {
if (namePos >= 0) {
this.name = this.name.slice(0, namePos) + "<b><u>" +
this.name.slice(namePos, namePos + searchStr.length) + "</u></b>" +
this.name.slice(namePos + searchStr.length);
this.name = `${this.name.slice(0, namePos)}<b><u>${
this.name.slice(namePos, namePos + searchStr.length)}</u></b>${
this.name.slice(namePos + searchStr.length)}`;
}
if (this.description && descPos >= 0) {
this.description = this.description.slice(0, descPos) + "<b><u>" +
this.description.slice(descPos, descPos + searchStr.length) + "</u></b>" +
this.description.slice(descPos + searchStr.length);
this.description = `${this.description.slice(0, descPos)}<b><u>${
this.description.slice(descPos, descPos + searchStr.length)}</u></b>${
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 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;
// Remove HTML tags
text = text.replace(/&/g, "&amp;")
text = `${text.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/\n/g, "&#10;")
// Convert placeholders to tags
.replace(startPlaceholderRegex, "<span class=\""+cssClass+"\">")
.replace(endPlaceholderRegex, "</span>") + "&nbsp;";
.replace(startPlaceholderRegex, `<span class="${cssClass}">`)
.replace(endPlaceholderRegex, "</span>")}&nbsp;`;
// Adjust width to allow for scrollbars
highlighter.style.width = textarea.clientWidth + "px";
highlighter.style.width = `${textarea.clientWidth}px`;
highlighter.innerHTML = text;
highlighter.scrollTop = textarea.scrollTop;
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 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();
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);
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 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 +
"<br>length: " + lengthStr +
"<br>lines: " + linesStr;
document.getElementById("output-info").innerHTML = `time: ${timeStr
}<br>length: ${lengthStr
}<br>lines: ${linesStr}`;
document.getElementById("input-selection-info").innerHTML = "";
document.getElementById("output-selection-info").innerHTML = "";
};
@ -134,7 +134,7 @@ OutputWaiter.prototype.saveClick = function() {
if (filename) {
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);
// 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 button = el.parentNode.parentNode.previousSibling;
button.innerHTML = el.textContent + " <span class='caret'></span>";
button.innerHTML = `${el.textContent} <span class='caret'></span>`;
this.ingChange();
};

View file

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