mirror of
https://github.com/gchq/CyberChef
synced 2026-02-11 05:53:18 +00:00
Fix freeze when output text decoding fails (#1573)
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
|
||||
import Dish from "../../core/Dish.mjs";
|
||||
import DishError from "../../core/errors/DishError.mjs";
|
||||
import { CHR_ENC_SIMPLE_REVERSE_LOOKUP } from "../../core/lib/ChrEnc.mjs";
|
||||
import Utils from "../../core/Utils.mjs";
|
||||
import cptable from "codepage";
|
||||
import loglevelMessagePrefix from "loglevel-message-prefix";
|
||||
@@ -98,7 +100,7 @@ async function bufferToStr(data) {
|
||||
try {
|
||||
str = cptable.utils.decode(data.encoding, new Uint8Array(data.buffer));
|
||||
} catch (err) {
|
||||
str = err;
|
||||
str = new DishError(`Error decoding buffer with encoding ${CHR_ENC_SIMPLE_REVERSE_LOOKUP[data.encoding]}: ${err.message}`).toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user