Skip to content

Commit 70e5040

Browse files
authored
fix: escape script vars (#788)
1 parent 395f461 commit 70e5040

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

examples/mcp-client/src/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ export class MyAgent extends Agent {
1212
status: 200
1313
});
1414
} else {
15+
const safeError = JSON.stringify(result.authError || "Unknown error");
1516
return new Response(
16-
`<script>alert('Authentication failed: ${result.authError}'); window.close();</script>`,
17+
`<script>alert('Authentication failed: ' + ${safeError}); window.close();</script>`,
1718
{
1819
headers: { "content-type": "text/html" },
1920
status: 200

site/ai-playground/src/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ export class Playground extends AIChatAgent<Env, PlaygroundState> {
7575
status: 200
7676
});
7777
}
78+
const safeError = JSON.stringify(result.authError || "Unknown error");
7879
return new Response(
79-
`<script>alert('Authentication failed: ${result.authError}'); window.close();</script>`,
80+
`<script>alert('Authentication failed: ' + ${safeError}); window.close();</script>`,
8081
{
8182
headers: { "content-type": "text/html" },
8283
status: 200

0 commit comments

Comments
 (0)