mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Operations can now set options from within the worker
This commit is contained in:
parent
13f07abb8a
commit
f6b52b7c82
10 changed files with 81 additions and 38 deletions
|
@ -234,7 +234,7 @@ const Utils = {
|
|||
* @returns {string}
|
||||
*/
|
||||
printable: function(str, preserveWs) {
|
||||
if (typeof window !== "undefined" && window.app && !window.app.options.treatAsUtf8) {
|
||||
if (ENVIRONMENT_IS_WEB() && window.app && !window.app.options.treatAsUtf8) {
|
||||
str = Utils.byteArrayToChars(Utils.strToByteArray(str));
|
||||
}
|
||||
|
||||
|
@ -384,8 +384,12 @@ const Utils = {
|
|||
let wordArray = CryptoJS.enc.Utf8.parse(str),
|
||||
byteArray = Utils.wordArrayToByteArray(wordArray);
|
||||
|
||||
if (typeof window !== "undefined" && str.length !== wordArray.sigBytes) {
|
||||
window.app.options.attemptHighlight = false;
|
||||
if (str.length !== wordArray.sigBytes) {
|
||||
if (ENVIRONMENT_IS_WORKER()) {
|
||||
self.setOption("attemptHighlight", false);
|
||||
} else if (ENVIRONMENT_IS_WEB()) {
|
||||
window.app.options.attemptHighlight = false;
|
||||
}
|
||||
}
|
||||
return byteArray;
|
||||
},
|
||||
|
@ -448,8 +452,13 @@ const Utils = {
|
|||
let wordArray = new CryptoJS.lib.WordArray.init(words, byteArray.length),
|
||||
str = CryptoJS.enc.Utf8.stringify(wordArray);
|
||||
|
||||
if (typeof window !== "undefined" && str.length !== wordArray.sigBytes)
|
||||
window.app.options.attemptHighlight = false;
|
||||
if (str.length !== wordArray.sigBytes) {
|
||||
if (ENVIRONMENT_IS_WORKER()) {
|
||||
self.setOption("attemptHighlight", false);
|
||||
} else if (ENVIRONMENT_IS_WEB()) {
|
||||
window.app.options.attemptHighlight = false;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
} catch (err) {
|
||||
// If it fails, treat it as ANSI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue