Skip to content

Commit 2e3b4ab

Browse files
Leon-SK668steipete
andauthored
fix(scripts): preserve emoji in dev tooling previews (#109469)
Co-authored-by: Peter Steinberger <[email protected]>
1 parent 3b1667e commit 2e3b4ab

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎scripts/lib/dev-tooling-safety.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Dev Tooling Safety script supports OpenClaw repository automation.
22
import path from "node:path";
3+
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
34
import { redactSensitiveText } from "../../src/logging/redact.js";
45

56
const REDACT_OPTIONS = { mode: "tools" } as const;
@@ -13,7 +14,7 @@ export function previewForDevToolLog(value: string, maxChars = 400): string {
1314
if (redacted.length <= maxChars) {
1415
return redacted;
1516
}
16-
return `${redacted.slice(0, Math.max(0, maxChars - 3))}...`;
17+
return `${truncateUtf16Safe(redacted, Math.max(0, maxChars - 3))}...`;
1718
}
1819

1920
export function maskIdentifier(value: string | undefined, keepStart = 6, keepEnd = 4): string {

‎test/scripts/dev-tooling-safety.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ describe("dev tooling safety helpers", () => {
219219
);
220220
expect(maskIdentifier("session-key-abcdef123456")).toBe("sessio...3456");
221221
});
222+
223+
it("does not split boundary emoji in script log previews", () => {
224+
expect(previewForDevToolLog("123456😀tail", 10)).toBe("123456...");
225+
});
222226
});
223227

224228
describe("script-specific dev tooling hardening", () => {

0 commit comments

Comments
 (0)