Commit b0f351a
committed
fix: prevent ReDoS vulnerability in regex patterns
Replace non-capturing groups (?:\n|$) with positive lookaheads (?=\n|$)
in regex patterns to prevent catastrophic backtracking and ReDoS attacks.
The pattern ([^+\n]+?)(?:\n|$) uses a lazy quantifier followed by a
non-capturing group, which can cause super-linear runtime when the input
doesn't match. Using positive lookahead (?=\n|$) prevents backtracking
by not consuming characters, making the regex safe from ReDoS.
Fixed patterns in:
- Invoice Date patterns (2 regexes)
- Due Date patterns (2 regexes)
- Service patterns (2 regexes)
All patterns now use (?=\n|$) instead of (?:\n|$) to prevent ReDoS.1 parent b54cbb2 commit b0f351a
1 file changed
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1056 | 1056 | | |
1057 | 1057 | | |
1058 | 1058 | | |
1059 | | - | |
1060 | | - | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
1061 | 1062 | | |
1062 | 1063 | | |
1063 | 1064 | | |
1064 | | - | |
1065 | | - | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
1066 | 1068 | | |
1067 | 1069 | | |
1068 | 1070 | | |
1069 | | - | |
1070 | | - | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
1071 | 1074 | | |
1072 | 1075 | | |
1073 | 1076 | | |
| |||
0 commit comments