Skip to content

Commit e52debc

Browse files
committed
fix(playwright): escape closing script tag in HTML reporter
Prevent issues with inline script content in Playwright HTML reporter by escaping closing script tags properly.
1 parent 75d2980 commit e52debc

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

patches/playwright@1.59.1.patch

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--- a/lib/reporters/html.js
2+
+++ b/lib/reporters/html.js
3+
@@ -170,6 +170,9 @@
4+
return true;
5+
return void 0;
6+
}
7+
+function escapeClosingScriptTag(text) {
8+
+ return text.replace(/<\/script/gi, "<\\/script");
9+
+}
10+
function standaloneDefaultFolder() {
11+
return reportFolderFromEnv() ?? (0, import_util.resolveReporterOutputPath)("playwright-report", process.cwd(), void 0);
12+
}
13+
@@ -325,7 +328,7 @@
14+
import_fs.default.promises.readFile(import_path.default.join(appFolder, "report.js"), "utf-8"),
15+
import_fs.default.promises.readFile(import_path.default.join(appFolder, "report.css"), "utf-8")
16+
]);
17+
- html = html.replace(/<script type="module"[^>]*><\/script>/, () => `<script type="module">${js}</script>`);
18+
+ html = html.replace(/<script type="module"[^>]*><\/script>/, () => `<script type="module">${escapeClosingScriptTag(js)}</script>`);
19+
html = html.replace(/<link rel="stylesheet"[^>]*>/, () => `<style type='text/css'>${css}</style>`);
20+
await import_fs.default.promises.writeFile(reportIndexFile, html);
21+
}

0 commit comments

Comments
 (0)