mirror of
https://github.com/gchq/CyberChef
synced 2026-02-22 12:24:11 +00:00
correct translation from node Buffer to byte array
This commit is contained in:
@@ -36,7 +36,6 @@ class Dish {
|
||||
* literal input
|
||||
*/
|
||||
constructor(dishOrInput=null, type = null) {
|
||||
|
||||
this.value = [];
|
||||
this.type = Dish.BYTE_ARRAY;
|
||||
|
||||
@@ -46,7 +45,7 @@ class Dish {
|
||||
dishOrInput.hasOwnProperty("type")) {
|
||||
this.set(dishOrInput.value, dishOrInput.type);
|
||||
// input and type defined separately
|
||||
} else if (dishOrInput && type) {
|
||||
} else if (dishOrInput && type !== null) {
|
||||
this.set(dishOrInput, type);
|
||||
// No type declared, so infer it.
|
||||
} else if (dishOrInput) {
|
||||
|
||||
@@ -22,9 +22,9 @@ class NodeDish extends Dish {
|
||||
|
||||
// Allow `fs` file input:
|
||||
// Any node fs Buffers transformed to array buffer
|
||||
// NOT Buffer.buff, as this makes a buffer of the whole object.
|
||||
// Use Array.from as Uint8Array doesnt pass instanceof Array test
|
||||
if (Buffer.isBuffer(inputOrDish)) {
|
||||
inputOrDish = new Uint8Array(inputOrDish).buffer;
|
||||
inputOrDish = Array.from(inputOrDish);
|
||||
type = Dish.BYTE_ARRAY;
|
||||
}
|
||||
super(inputOrDish, type);
|
||||
|
||||
Reference in New Issue
Block a user