mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-17 09:28:31 +01:00
Fix switchClick not always being fired.
Run detectFileType on switched output
This commit is contained in:
parent
05d81eb734
commit
c529a406cd
2 changed files with 21 additions and 14 deletions
|
@ -1229,18 +1229,15 @@ class OutputWaiter {
|
||||||
* Handler for switch click events.
|
* Handler for switch click events.
|
||||||
* Moves the current output into the input textarea.
|
* Moves the current output into the input textarea.
|
||||||
*/
|
*/
|
||||||
switchClick() {
|
async switchClick() {
|
||||||
const active = this.getActive(true);
|
const active = await this.getDishBuffer(this.getOutputDish(this.manager.tabs.getActiveOutputTab()));
|
||||||
const transferable = (typeof active === "string" ? undefined : [active]);
|
|
||||||
if (typeof active === "string") {
|
|
||||||
this.manager.input.inputWorker.postMessage({
|
this.manager.input.inputWorker.postMessage({
|
||||||
action: "inputSwitch",
|
action: "inputSwitch",
|
||||||
data: {
|
data: {
|
||||||
inputNum: this.manager.tabs.getActiveInputTab(),
|
inputNum: this.manager.tabs.getActiveInputTab(),
|
||||||
outputData: active
|
outputData: active
|
||||||
}
|
}
|
||||||
}, transferable);
|
}, [active]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Utils from "../../core/Utils";
|
import Utils from "../../core/Utils";
|
||||||
|
import {detectFileType} from "../../core/lib/FileType";
|
||||||
|
|
||||||
self.maxWorkers = 4;
|
self.maxWorkers = 4;
|
||||||
self.maxTabs = 1;
|
self.maxTabs = 1;
|
||||||
|
@ -1023,12 +1024,21 @@ self.inputSwitch = function(switchData) {
|
||||||
if (currentInput === undefined || currentInput === null) return;
|
if (currentInput === undefined || currentInput === null) return;
|
||||||
|
|
||||||
if (typeof switchData.outputData === "object") {
|
if (typeof switchData.outputData === "object") {
|
||||||
|
const output = new Uint8Array(switchData.outputData),
|
||||||
|
types = detectFileType(output);
|
||||||
|
let type = "unknown",
|
||||||
|
ext = "dat";
|
||||||
|
if (types.length) {
|
||||||
|
type = types[0].mime;
|
||||||
|
ext = types[0].extension.split(",", 1)[0];
|
||||||
|
}
|
||||||
|
|
||||||
// ArrayBuffer
|
// ArrayBuffer
|
||||||
currentInput.data = {
|
currentInput.data = {
|
||||||
fileBuffer: switchData.outputData,
|
fileBuffer: switchData.outputData,
|
||||||
name: "output.dat",
|
name: `output.${ext}`,
|
||||||
size: switchData.outputData.byteLength.toLocaleString(),
|
size: switchData.outputData.byteLength.toLocaleString(),
|
||||||
type: "unknown" // Could run detect file type here
|
type: type
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// String
|
// String
|
||||||
|
|
Loading…
Reference in a new issue