Fix formatting (#22474)

This commit is contained in:
Vincent Koc
2026-02-21 01:37:02 -05:00
committed by GitHub
parent 3002be76e4
commit c2f5628915
2 changed files with 11 additions and 3 deletions

View File

@@ -269,7 +269,9 @@ describe("web_search external content wrapping", () => {
results?: Array<{ description?: string }>;
};
expect(details.results?.[0]?.description).toMatch(/<<<EXTERNAL_UNTRUSTED_CONTENT id="[a-f0-9]{16}">>>/);
expect(details.results?.[0]?.description).toMatch(
/<<<EXTERNAL_UNTRUSTED_CONTENT id="[a-f0-9]{16}">>>/,
);
expect(details.results?.[0]?.description).toContain("Ignore previous instructions");
expect(details.externalContent).toMatchObject({
untrusted: true,

View File

@@ -148,8 +148,14 @@ function replaceMarkers(content: string): string {
const replacements: Array<{ start: number; end: number; value: string }> = [];
// Match markers with or without id attribute (handles both legacy and spoofed markers)
const patterns: Array<{ regex: RegExp; value: string }> = [
{ regex: /<<<EXTERNAL_UNTRUSTED_CONTENT(?:\s+id="[^"]{1,128}")?\s*>>>/gi, value: "[[MARKER_SANITIZED]]" },
{ regex: /<<<END_EXTERNAL_UNTRUSTED_CONTENT(?:\s+id="[^"]{1,128}")?\s*>>>/gi, value: "[[END_MARKER_SANITIZED]]" },
{
regex: /<<<EXTERNAL_UNTRUSTED_CONTENT(?:\s+id="[^"]{1,128}")?\s*>>>/gi,
value: "[[MARKER_SANITIZED]]",
},
{
regex: /<<<END_EXTERNAL_UNTRUSTED_CONTENT(?:\s+id="[^"]{1,128}")?\s*>>>/gi,
value: "[[END_MARKER_SANITIZED]]",
},
];
for (const pattern of patterns) {