diff --git a/src/core/Utils.js b/src/core/Utils.js index 8e1829f5..3794d972 100755 --- a/src/core/Utils.js +++ b/src/core/Utils.js @@ -388,7 +388,7 @@ const Utils = { var wordArray = CryptoJS.enc.Utf8.parse(str), byteArray = Utils.wordArrayToByteArray(wordArray); - if (str.length !== wordArray.sigBytes) + if (window && str.length !== wordArray.sigBytes) window.app.options.attemptHighlight = false; return byteArray; }, @@ -440,7 +440,7 @@ const Utils = { var wordArray = new CryptoJS.lib.WordArray.init(words, byteArray.length), str = CryptoJS.enc.Utf8.stringify(wordArray); - if (str.length !== wordArray.sigBytes) + if (window && str.length !== wordArray.sigBytes) window.app.options.attemptHighlight = false; return str; } catch (err) { diff --git a/src/core/operations/URL.js b/src/core/operations/URL.js index 9dde1798..a00ea9db 100755 --- a/src/core/operations/URL.js +++ b/src/core/operations/URL.js @@ -58,6 +58,10 @@ const URL_ = { * @returns {string} */ runParse: function(input, args) { + if (!document) { + throw "This operation only works in a browser."; + } + var a = document.createElement("a"); // Overwrite base href which will be the current CyberChef URL to reduce confusion. diff --git a/src/core/operations/UUID.js b/src/core/operations/UUID.js index 3ea0d36d..9302a350 100755 --- a/src/core/operations/UUID.js +++ b/src/core/operations/UUID.js @@ -17,7 +17,7 @@ const UUID = { * @returns {string} */ runGenerateV4: function(input, args) { - if (typeof(window.crypto) !== "undefined" && typeof(window.crypto.getRandomValues) !== "undefined") { + if (window && typeof(window.crypto) !== "undefined" && typeof(window.crypto.getRandomValues) !== "undefined") { var buf = new Uint32Array(4), i = 0; window.crypto.getRandomValues(buf);