mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 01:08:28 +00:00
fix(security): harden ACP prompt size guardrails
This commit is contained in:
@@ -153,6 +153,28 @@ describe("acp event mapper", () => {
|
||||
expect(text).toBe("Hello\nFile contents\n[Resource link (Spec)] https://example.com");
|
||||
});
|
||||
|
||||
it("counts newline separators toward prompt byte limits", () => {
|
||||
expect(() =>
|
||||
extractTextFromPrompt(
|
||||
[
|
||||
{ type: "text", text: "a" },
|
||||
{ type: "text", text: "b" },
|
||||
],
|
||||
2,
|
||||
),
|
||||
).toThrow(/maximum allowed size/i);
|
||||
|
||||
expect(
|
||||
extractTextFromPrompt(
|
||||
[
|
||||
{ type: "text", text: "a" },
|
||||
{ type: "text", text: "b" },
|
||||
],
|
||||
3,
|
||||
),
|
||||
).toBe("a\nb");
|
||||
});
|
||||
|
||||
it("extracts image blocks into gateway attachments", () => {
|
||||
const attachments = extractAttachmentsFromPrompt([
|
||||
{ type: "image", data: "abc", mimeType: "image/png" },
|
||||
|
||||
Reference in New Issue
Block a user