Skip to content

Commit 9da7fa4

Browse files
Merge pull request #151 from hansec/slow_fun_regex
Fix blocking due to very slow regex execution in "parseFunction"
2 parents bf52b35 + 6d26c9c commit 9da7fa4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const parseSubroutine = (line: TextLine) => {
7474
return _parse(line, MethodType.Subroutine);
7575
};
7676
export const _parse = (line: TextLine, type: MethodType) => {
77-
const functionRegEx = /([a-zA-Z]+(\([\w.=]+\))*)*\s*\bfunction\b\s*([a-zA-Z_][a-z0-9_]*)\s*\((\s*[a-z_][a-z0-9_,\s]*)*\s*(\)|\&)\s*(result\([a-z_][\w]*(\)|\&))*/i;
77+
const functionRegEx = /(?<=([a-zA-Z]+(\([\w.=]+\))*)*)\s*\bfunction\b\s*([a-zA-Z_][a-z0-9_]*)\s*\((\s*[a-z_][a-z0-9_,\s]*)*\s*(?:\)|\&)\s*(result\([a-z_][\w]*(?:\)|\&))*/i;
7878
const subroutineRegEx = /^\s*(?!\bend\b)\w*\s*\bsubroutine\b\s*([a-z][a-z0-9_]*)\s*(?:\((\s*[a-z][a-z0-9_,\s]*)*\s*(\)|\&))*/i;
7979
const regEx =
8080
type === MethodType.Subroutine ? subroutineRegEx : functionRegEx;

0 commit comments

Comments
 (0)