mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:59:30 +00:00
fix(imessage): keep CLI stderr tails UTF-16 safe (#102626)
* fix(imessage): keep CLI stderr tail truncation UTF-16 safe * test(imessage): hit stderr surrogate boundary * fix(imessage): use plugin sdk text helper --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
parent
11dda0e5fd
commit
4c55d46254
2 changed files with 9 additions and 1 deletions
|
|
@ -17,4 +17,11 @@ describe("iMessage CLI output bounds", () => {
|
|||
|
||||
expect(result).toBe("recent-error");
|
||||
});
|
||||
|
||||
it("does not split a surrogate pair at the tail boundary", () => {
|
||||
const input = `x🚀${"y".repeat(10)}`;
|
||||
|
||||
expect(input.slice(-11)).toBe(`\ude80${"y".repeat(10)}`);
|
||||
expect(appendIMessageCliStderrTail("", input, 11)).toBe("y".repeat(10));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// Imessage plugin module implements cli output behavior.
|
||||
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
||||
import { sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
||||
|
||||
const IMESSAGE_CLI_STDOUT_MAX_CHARS = 8 * 1024 * 1024;
|
||||
const IMESSAGE_CLI_STDERR_TAIL_CHARS = 64 * 1024;
|
||||
|
|
@ -50,5 +51,5 @@ export function appendIMessageCliStderrTail(
|
|||
maxChars = IMESSAGE_CLI_STDERR_TAIL_CHARS,
|
||||
): string {
|
||||
const next = current + chunkToString(chunk);
|
||||
return next.length > maxChars ? next.slice(-maxChars) : next;
|
||||
return next.length > maxChars ? sliceUtf16Safe(next, -maxChars) : next;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue