mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 08:16:17 -04:00
Merge branch 'master' of github.com:gchq/CyberChef
This commit is contained in:
commit
9391b947c6
7 changed files with 68 additions and 14 deletions
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cyberchef",
|
"name": "cyberchef",
|
||||||
"version": "6.0.1",
|
"version": "6.0.2",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cyberchef",
|
"name": "cyberchef",
|
||||||
"version": "6.0.1",
|
"version": "6.0.2",
|
||||||
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
||||||
"author": "n1474335 <n1474335@gmail.com>",
|
"author": "n1474335 <n1474335@gmail.com>",
|
||||||
"homepage": "https://gchq.github.io/CyberChef",
|
"homepage": "https://gchq.github.io/CyberChef",
|
||||||
|
|
|
@ -240,7 +240,7 @@ App.prototype.initialiseSplitter = function() {
|
||||||
App.prototype.loadLocalStorage = function() {
|
App.prototype.loadLocalStorage = function() {
|
||||||
// Load options
|
// Load options
|
||||||
let lOptions;
|
let lOptions;
|
||||||
if (localStorage.options !== undefined) {
|
if (this.isLocalStorageAvailable() && localStorage.options !== undefined) {
|
||||||
lOptions = JSON.parse(localStorage.options);
|
lOptions = JSON.parse(localStorage.options);
|
||||||
}
|
}
|
||||||
this.manager.options.load(lOptions);
|
this.manager.options.load(lOptions);
|
||||||
|
@ -256,13 +256,17 @@ App.prototype.loadLocalStorage = function() {
|
||||||
* If the user currently has no saved favourites, the defaults from the view constructor are used.
|
* If the user currently has no saved favourites, the defaults from the view constructor are used.
|
||||||
*/
|
*/
|
||||||
App.prototype.loadFavourites = function() {
|
App.prototype.loadFavourites = function() {
|
||||||
let favourites = localStorage.favourites &&
|
let favourites;
|
||||||
localStorage.favourites.length > 2 ?
|
|
||||||
|
if (this.isLocalStorageAvailable()) {
|
||||||
|
favourites = localStorage.favourites && localStorage.favourites.length > 2 ?
|
||||||
JSON.parse(localStorage.favourites) :
|
JSON.parse(localStorage.favourites) :
|
||||||
this.dfavourites;
|
this.dfavourites;
|
||||||
|
|
||||||
favourites = this.validFavourites(favourites);
|
favourites = this.validFavourites(favourites);
|
||||||
this.saveFavourites(favourites);
|
this.saveFavourites(favourites);
|
||||||
|
} else {
|
||||||
|
favourites = this.dfavourites;
|
||||||
|
}
|
||||||
|
|
||||||
const favCat = this.categories.filter(function(c) {
|
const favCat = this.categories.filter(function(c) {
|
||||||
return c.name === "Favourites";
|
return c.name === "Favourites";
|
||||||
|
@ -306,6 +310,15 @@ App.prototype.validFavourites = function(favourites) {
|
||||||
* @param {string[]} favourites - A list of the user's favourite operations
|
* @param {string[]} favourites - A list of the user's favourite operations
|
||||||
*/
|
*/
|
||||||
App.prototype.saveFavourites = function(favourites) {
|
App.prototype.saveFavourites = function(favourites) {
|
||||||
|
if (!this.isLocalStorageAvailable()) {
|
||||||
|
this.alert(
|
||||||
|
"Your security settings do not allow access to local storage so your favourites cannot be saved.",
|
||||||
|
"danger",
|
||||||
|
5000
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
localStorage.setItem("favourites", JSON.stringify(this.validFavourites(favourites)));
|
localStorage.setItem("favourites", JSON.stringify(this.validFavourites(favourites)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -503,6 +516,22 @@ App.prototype.setCompileMessage = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the browser supports Local Storage and if it is accessible.
|
||||||
|
*
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
App.prototype.isLocalStorageAvailable = function() {
|
||||||
|
try {
|
||||||
|
if (!localStorage) return false;
|
||||||
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
// Access to LocalStorage is denied
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pops up a message to the user and writes it to the console log.
|
* Pops up a message to the user and writes it to the console log.
|
||||||
*
|
*
|
||||||
|
|
|
@ -254,6 +254,15 @@ ControlsWaiter.prototype.loadClick = function() {
|
||||||
* Saves the recipe specified in the save textarea to local storage.
|
* Saves the recipe specified in the save textarea to local storage.
|
||||||
*/
|
*/
|
||||||
ControlsWaiter.prototype.saveButtonClick = function() {
|
ControlsWaiter.prototype.saveButtonClick = function() {
|
||||||
|
if (!this.app.isLocalStorageAvailable()) {
|
||||||
|
this.app.alert(
|
||||||
|
"Your security settings do not allow access to local storage so your recipe cannot be saved.",
|
||||||
|
"danger",
|
||||||
|
5000
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const recipeName = Utils.escapeHtml(document.getElementById("save-name").value);
|
const recipeName = Utils.escapeHtml(document.getElementById("save-name").value);
|
||||||
const recipeStr = document.querySelector("#save-texts .tab-pane.active textarea").value;
|
const recipeStr = document.querySelector("#save-texts .tab-pane.active textarea").value;
|
||||||
|
|
||||||
|
@ -283,6 +292,8 @@ ControlsWaiter.prototype.saveButtonClick = function() {
|
||||||
* Populates the list of saved recipes in the load dialog box from local storage.
|
* Populates the list of saved recipes in the load dialog box from local storage.
|
||||||
*/
|
*/
|
||||||
ControlsWaiter.prototype.populateLoadRecipesList = function() {
|
ControlsWaiter.prototype.populateLoadRecipesList = function() {
|
||||||
|
if (!this.app.isLocalStorageAvailable()) return false;
|
||||||
|
|
||||||
const loadNameEl = document.getElementById("load-name");
|
const loadNameEl = document.getElementById("load-name");
|
||||||
|
|
||||||
// Remove current recipes from select
|
// Remove current recipes from select
|
||||||
|
@ -313,6 +324,8 @@ ControlsWaiter.prototype.populateLoadRecipesList = function() {
|
||||||
* Removes the currently selected recipe from local storage.
|
* Removes the currently selected recipe from local storage.
|
||||||
*/
|
*/
|
||||||
ControlsWaiter.prototype.loadDeleteClick = function() {
|
ControlsWaiter.prototype.loadDeleteClick = function() {
|
||||||
|
if (!this.app.isLocalStorageAvailable()) return false;
|
||||||
|
|
||||||
const id = parseInt(document.getElementById("load-name").value, 10);
|
const id = parseInt(document.getElementById("load-name").value, 10);
|
||||||
const rawSavedRecipes = localStorage.savedRecipes ?
|
const rawSavedRecipes = localStorage.savedRecipes ?
|
||||||
JSON.parse(localStorage.savedRecipes) : [];
|
JSON.parse(localStorage.savedRecipes) : [];
|
||||||
|
@ -328,6 +341,8 @@ ControlsWaiter.prototype.loadDeleteClick = function() {
|
||||||
* Displays the selected recipe in the load text box.
|
* Displays the selected recipe in the load text box.
|
||||||
*/
|
*/
|
||||||
ControlsWaiter.prototype.loadNameChange = function(e) {
|
ControlsWaiter.prototype.loadNameChange = function(e) {
|
||||||
|
if (!this.app.isLocalStorageAvailable()) return false;
|
||||||
|
|
||||||
const el = e.target;
|
const el = e.target;
|
||||||
const savedRecipes = localStorage.savedRecipes ?
|
const savedRecipes = localStorage.savedRecipes ?
|
||||||
JSON.parse(localStorage.savedRecipes) : [];
|
JSON.parse(localStorage.savedRecipes) : [];
|
||||||
|
|
|
@ -229,7 +229,7 @@ OperationsWaiter.prototype.editFavouritesClick = function(e) {
|
||||||
filter: ".remove-icon",
|
filter: ".remove-icon",
|
||||||
onFilter: function (evt) {
|
onFilter: function (evt) {
|
||||||
const el = editableList.closest(evt.item);
|
const el = editableList.closest(evt.item);
|
||||||
if (el) {
|
if (el && el.parentNode) {
|
||||||
$(el).popover("destroy");
|
$(el).popover("destroy");
|
||||||
el.parentNode.removeChild(el);
|
el.parentNode.removeChild(el);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,8 @@ OptionsWaiter.prototype.switchChange = function(e, state) {
|
||||||
const option = el.getAttribute("option");
|
const option = el.getAttribute("option");
|
||||||
|
|
||||||
this.app.options[option] = state;
|
this.app.options[option] = state;
|
||||||
|
|
||||||
|
if (this.app.isLocalStorageAvailable())
|
||||||
localStorage.setItem("options", JSON.stringify(this.app.options));
|
localStorage.setItem("options", JSON.stringify(this.app.options));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -102,6 +104,8 @@ OptionsWaiter.prototype.numberChange = function(e) {
|
||||||
const option = el.getAttribute("option");
|
const option = el.getAttribute("option");
|
||||||
|
|
||||||
this.app.options[option] = parseInt(el.value, 10);
|
this.app.options[option] = parseInt(el.value, 10);
|
||||||
|
|
||||||
|
if (this.app.isLocalStorageAvailable())
|
||||||
localStorage.setItem("options", JSON.stringify(this.app.options));
|
localStorage.setItem("options", JSON.stringify(this.app.options));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,6 +121,8 @@ OptionsWaiter.prototype.selectChange = function(e) {
|
||||||
const option = el.getAttribute("option");
|
const option = el.getAttribute("option");
|
||||||
|
|
||||||
this.app.options[option] = el.value;
|
this.app.options[option] = el.value;
|
||||||
|
|
||||||
|
if (this.app.isLocalStorageAvailable())
|
||||||
localStorage.setItem("options", JSON.stringify(this.app.options));
|
localStorage.setItem("options", JSON.stringify(this.app.options));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,11 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Load theme before the preloader is shown
|
// Load theme before the preloader is shown
|
||||||
|
try {
|
||||||
document.querySelector(":root").className = (JSON.parse(localStorage.getItem("options")) || {}).theme;
|
document.querySelector(":root").className = (JSON.parse(localStorage.getItem("options")) || {}).theme;
|
||||||
|
} catch (err) {
|
||||||
|
// LocalStorage access is denied by security settings
|
||||||
|
}
|
||||||
|
|
||||||
// Define loading messages
|
// Define loading messages
|
||||||
const loadingMsgs = [
|
const loadingMsgs = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue