Skip to content

Commit c8241a1

Browse files
authored
Merge pull request #5 from earlution/alert-autofix-12
Potential fix for code scanning alert no. 12: Bad HTML filtering regexp
2 parents d46b642 + 33f5a23 commit c8241a1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

scripts/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ function buildDataPage() {
130130
version = pkg.version || version;
131131
} catch (_) {}
132132

133-
const moduleMatch = html.match(/<script>([\s\S]*?)<\/script>/);
133+
const moduleMatch = html.match(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/i);
134134
const moduleScript = moduleMatch ? moduleMatch[1] : '';
135135

136136
const js = [inline(chrome), moduleScript].join('\n\n');
137137

138138
const output = html
139139
.replace(/<style>[\s\S]*?<\/style>/, `<style>\n${css}\n</style>`)
140-
.replace(/<script>[\s\S]*?<\/script>/, `<script>\n${js}\n</script>`)
140+
.replace(/<script\b[^>]*>[\s\S]*?<\/script\s*>/i, `<script>\n${js}\n</script>`)
141141
.replace(/\{\{VERSION\}\}/g, version)
142142
.replace(/const ACTORS = __ACTORS \|\| \[\];/, actors.trim() + '\n' + groupsJs + '\nconst ACTORS = __ACTORS || [];');
143143

0 commit comments

Comments
 (0)