fix: avoid invalid UTF-16 in truncation (#567)

This commit is contained in:
Peter Steinberger
2026-01-09 14:19:25 +01:00
parent fd535a50d3
commit 63f5fa47de
7 changed files with 70 additions and 7 deletions

View File

@@ -24,6 +24,7 @@ import {
} from "../pairing/pairing-store.js";
import { resolveAgentRoute } from "../routing/resolve-route.js";
import type { RuntimeEnv } from "../runtime.js";
import { truncateUtf16Safe } from "../utils.js";
import { resolveIMessageAccount } from "./accounts.js";
import { createIMessageRpcClient } from "./client.js";
import { sendMessageIMessage } from "./send.js";
@@ -413,7 +414,7 @@ export async function monitorIMessageProvider(
}
if (shouldLogVerbose()) {
const preview = body.slice(0, 200).replace(/\n/g, "\\n");
const preview = truncateUtf16Safe(body, 200).replace(/\n/g, "\\n");
logVerbose(
`imessage inbound: chatId=${chatId ?? "unknown"} from=${ctxPayload.From} len=${body.length} preview="${preview}"`,
);