Skip to content

Commit af6b05f

Browse files
committed
fix(hooks): use truncateUtf16Safe for hook console value truncation
Replace .slice(0, 500) with truncateUtf16Safe() to prevent UTF-16 surrogate pair corruption in sanitized hook output.
1 parent e595a8c commit af6b05f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/gateway/server/hooks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
resolveTimestampMsToIsoString,
66
} from "@openclaw/normalization-core/number-coercion";
77
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
8+
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
89
import { sanitizeInboundSystemTags } from "../../auto-reply/reply/inbound-text.js";
910
import type { CliDeps } from "../../cli/deps.types.js";
1011
import { getRuntimeConfig } from "../../config/io.js";
@@ -68,7 +69,7 @@ function sanitizeHookConsoleValue(value: string | undefined): string | undefined
6869
const code = char.charCodeAt(0);
6970
return code < 32 || code === 127 ? " " : char;
7071
}).join("");
71-
return withoutControlChars.replace(/\s+/gu, " ").trim().slice(0, 500);
72+
return truncateUtf16Safe(withoutControlChars.replace(/\s+/gu, " ").trim(), 500);
7273
}
7374

7475
function formatHookRunWarningConsoleMessage(params: {

0 commit comments

Comments
 (0)