Skip to content

Commit a3ece3b

Browse files
committed
fix(launchd): use truncateUtf16Safe for daemon output truncation
Replace .slice(0, 1000) with truncateUtf16Safe() to prevent UTF-16 surrogate pair corruption in LaunchAgent command output.
1 parent e595a8c commit a3ece3b

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/daemon/launchd.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import fs from "node:fs/promises";
33
import path from "node:path";
44
import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce";
5+
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
56
import { sanitizeForLog } from "../../packages/terminal-core/src/ansi.js";
67
import { normalizeEnvVarKey } from "../infra/host-env-security.js";
78
import { parseStrictInteger, parseStrictPositiveInteger } from "../infra/parse-finite-number.js";
@@ -759,10 +760,12 @@ function formatLaunchctlResultDetail(res: {
759760
stderr: string;
760761
code: number;
761762
}): string {
762-
return sanitizeForLog((res.stderr || res.stdout).replace(/[\r\n\t]+/g, " "))
763-
.replace(/\s+/g, " ")
764-
.trim()
765-
.slice(0, 1000);
763+
return truncateUtf16Safe(
764+
sanitizeForLog((res.stderr || res.stdout).replace(/[\r\n\t]+/g, " "))
765+
.replace(/\s+/g, " ")
766+
.trim(),
767+
1000,
768+
);
766769
}
767770

768771
async function bootoutLaunchAgentOrThrow(params: {

0 commit comments

Comments
 (0)