From 5c9510c2b8260711f720aef9e1c8ee446662290a Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Thu, 21 May 2026 11:43:47 +0900 Subject: [PATCH 1/2] fix(browser): escape inline orchestrator scripts Co-authored-by: Codex --- packages/browser/src/node/serverOrchestrator.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/browser/src/node/serverOrchestrator.ts b/packages/browser/src/node/serverOrchestrator.ts index e730fad0c555..ff84adf4c9be 100644 --- a/packages/browser/src/node/serverOrchestrator.ts +++ b/packages/browser/src/node/serverOrchestrator.ts @@ -61,7 +61,7 @@ export async function resolveOrchestrator( for (const attr in script.attrs || {}) { html += `${attr}="${script.attrs![attr]}" ` } - html += `>${script.children}` + html += `>${escapeInlineScript(typeof script.children === 'string' ? script.children : '')}` return html }).join('\n') } @@ -96,8 +96,14 @@ export async function resolveOrchestrator( __VITEST_FAVICON__: globalServer.faviconUrl, __VITEST_TITLE__: 'Vitest Browser Runner', __VITEST_SCRIPTS__: globalServer.orchestratorScripts, - __VITEST_INJECTOR__: ``, + __VITEST_INJECTOR__: ``, __VITEST_ERROR_CATCHER__: ``, __VITEST_SESSION_ID__: JSON.stringify(sessionId), }) } + +function escapeInlineScript(content: string): string { + return content + .replace(/