Skip to content

Write HTML. Render video. Built for agents.

test(bundler): parse scripts via linkedom, not regex

James3d370c40640e
diff --git a/packages/core/src/compiler/htmlBundler.test.ts b/packages/core/src/compiler/htmlBundler.test.ts
index c70f49037f..665ff98111 100644
--- a/packages/core/src/compiler/htmlBundler.test.ts
+++ b/packages/core/src/compiler/htmlBundler.test.ts
@@ -105,12 +105,12 @@ describe("bundleToSingleHtml", () => {
const bundled = await bundleToSingleHtml(dir);
// Run every inline script body through esbuild; if the line comment ate
// the separator, parse would fail with an unexpected-token error somewhere
- // around the chunk boundary.
+ // around the chunk boundary. Use a real HTML parser (CodeQL flags regex-
+ // based script extraction as bad-tag-filter).
const { transformSync } = await import("esbuild");
- const re = /<script\b[^>]*>([\s\S]*?)<\/script[^>]*>/gi;
- let m: RegExpExecArray | null;
- while ((m = re.exec(bundled)) !== null) {
- const body = m[1];
+ const { document } = parseHTML(bundled);
+ for (const script of document.querySelectorAll("script")) {
+ const body = script.textContent;
if (!body || !body.trim()) continue;
expect(() => transformSync(body, { loader: "js", minify: false })).not.toThrow();
}