From dd26c09003f3b5132c76082f2df4bb6bb236314b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BF=E3=81=91CAT?= Date: Fri, 30 Jan 2026 00:00:17 +0900 Subject: [PATCH] Exclude Delete character from hex dump output (#2086) Co-authored-by: GCHQ Developer C85297 <95289555+C85297@users.noreply.github.com> --- src/core/Utils.mjs | 2 +- tests/node/tests/Utils.mjs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/Utils.mjs b/src/core/Utils.mjs index a9c381d76..eae86374b 100755 --- a/src/core/Utils.mjs +++ b/src/core/Utils.mjs @@ -177,7 +177,7 @@ class Utils { */ static printable(str, preserveWs=false, onlyAscii=false) { if (onlyAscii) { - return str.replace(/[^\x20-\x7f]/g, "."); + return str.replace(/[^\x20-\x7e]/g, "."); } // eslint-disable-next-line no-misleading-character-class diff --git a/tests/node/tests/Utils.mjs b/tests/node/tests/Utils.mjs index 8dbf37ae7..5ee7c9362 100644 --- a/tests/node/tests/Utils.mjs +++ b/tests/node/tests/Utils.mjs @@ -20,4 +20,10 @@ TestRegister.addApiTests([ assert.equal(Utils.parseEscapedChars("\\\\\\'"), "\\'"); }), + it("Utils: should replace delete character", () => { + assert.equal( + Utils.printable("\x7e\x7f\x80\xa7", false, true), + "\x7e...", + ); + }), ]);