Skip to content

Commit

Permalink
#747: improve regex to recognize edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Feb 20, 2023
1 parent c4a571b commit 3343d1c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,12 @@ const Util = {
if (!code) {
return null;
}
const scriptRegex = /^<script .*?>(.*)<\/script>$/ms;
// \s* whitespace characters, zero or more times
// [^>]*? any character that is not a >, zero or more times, un-greedily
// (.*) capture any character, zero or more times
// /ms multiline and dotall flags
// ideally the code looks like <script runat="server">...</script>
const scriptRegex = /^<\s*script [^>]*?>(.*)<\/\s*script\s*>$/ms;
code = code.trim();
const regexMatches = scriptRegex.exec(code);
if (regexMatches?.length > 1) {
Expand Down

0 comments on commit 3343d1c

Please sign in to comment.