mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 16:56:15 -04:00
Add carriage return detection for pasted and switched inputs.
Fix switching the output to input not working properly. Add nicer confirmation boxes for zipping outputs.
This commit is contained in:
parent
9f2d1453ed
commit
f43a868607
6 changed files with 399 additions and 246 deletions
|
@ -202,6 +202,7 @@ self.bakeInput = function(inputNum, bakeId) {
|
|||
if (inputObj === null ||
|
||||
inputObj === undefined ||
|
||||
inputObj.status !== "loaded") {
|
||||
|
||||
self.postMessage({
|
||||
action: "queueInputError",
|
||||
data: {
|
||||
|
@ -441,7 +442,7 @@ self.updateTabHeader = function(inputNum) {
|
|||
*
|
||||
* @param {object} inputData
|
||||
* @param {number} inputData.inputNum - The input to get the data for
|
||||
* @param {boolean} inputData.silent - If false, the manager statechange event won't be fired
|
||||
* @param {boolean} inputData.silent - If false, the manager statechange event will be fired
|
||||
*/
|
||||
self.setInput = function(inputData) {
|
||||
const inputNum = inputData.inputNum;
|
||||
|
@ -590,7 +591,7 @@ self.updateInputObj = function(inputData) {
|
|||
const inputNum = inputData.inputNum;
|
||||
const data = inputData.data;
|
||||
|
||||
if (self.getInputObj(inputNum) === -1) return;
|
||||
if (self.getInputObj(inputNum) === undefined) return;
|
||||
|
||||
self.inputs[inputNum].data = data;
|
||||
};
|
||||
|
@ -663,11 +664,19 @@ self.handleLoaderMessage = function(r) {
|
|||
if ("fileBuffer" in r) {
|
||||
log.debug(`Input file ${inputNum} loaded.`);
|
||||
self.loadingInputs--;
|
||||
|
||||
self.updateInputValue({
|
||||
inputNum: inputNum,
|
||||
value: r.fileBuffer
|
||||
});
|
||||
|
||||
self.postMessage({
|
||||
action: "fileLoaded",
|
||||
data: {
|
||||
inputNum: inputNum
|
||||
}
|
||||
});
|
||||
|
||||
const idx = self.getLoaderWorkerIdx(r.id);
|
||||
self.loadNextFile(idx);
|
||||
} else if ("progress" in r) {
|
||||
|
@ -782,7 +791,7 @@ self.loadFiles = function(filesData) {
|
|||
}
|
||||
|
||||
self.getLoadProgress();
|
||||
self.setInput({inputNum: activeTab, silent: false});
|
||||
self.setInput({inputNum: activeTab, silent: true});
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1025,7 +1034,7 @@ self.inputSwitch = function(switchData) {
|
|||
const currentData = currentInput.data;
|
||||
if (currentInput === undefined || currentInput === null) return;
|
||||
|
||||
if (typeof switchData.outputData === "object") {
|
||||
if (typeof switchData.outputData !== "string") {
|
||||
const output = new Uint8Array(switchData.outputData),
|
||||
types = detectFileType(output);
|
||||
let type = "unknown",
|
||||
|
@ -1036,15 +1045,22 @@ self.inputSwitch = function(switchData) {
|
|||
}
|
||||
|
||||
// ArrayBuffer
|
||||
currentInput.data = {
|
||||
fileBuffer: switchData.outputData,
|
||||
name: `output.${ext}`,
|
||||
size: switchData.outputData.byteLength.toLocaleString(),
|
||||
type: type
|
||||
};
|
||||
self.updateInputObj({
|
||||
inputNum: switchData.inputNum,
|
||||
data: {
|
||||
fileBuffer: switchData.outputData,
|
||||
name: `output.${ext}`,
|
||||
size: switchData.outputData.byteLength.toLocaleString(),
|
||||
type: type
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// String
|
||||
currentInput.data = switchData.outputData;
|
||||
self.updateInputValue({
|
||||
inputNum: switchData.inputNum,
|
||||
value: switchData.outputData,
|
||||
force: true
|
||||
});
|
||||
}
|
||||
|
||||
self.postMessage({
|
||||
|
@ -1055,6 +1071,11 @@ self.inputSwitch = function(switchData) {
|
|||
}
|
||||
});
|
||||
|
||||
self.setInput({inputNum: switchData.inputNum, silent: false});
|
||||
self.postMessage({
|
||||
action: "fileLoaded",
|
||||
data: {
|
||||
inputNum: switchData.inputNum
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue