Skip to content

Commit

Permalink
Merge pull request #344 from mrmlnc/PR-338_fix_polynominal_regexp
Browse files Browse the repository at this point in the history
Fixing CodeQL alerts
  • Loading branch information
mrmlnc authored Jan 7, 2022
2 parents 3325450 + 4f5ff66 commit 9b41dbd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/utils/pattern.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,22 @@ describe('Utils → Pattern', () => {

it('should return false for unfinished glob extension', () => {
assert.ok(!util.isDynamicPattern('@('));
assert.ok(!util.isDynamicPattern('@' + '('.repeat(999999) + 'a'));
assert.ok(!util.isDynamicPattern('@(a'));
assert.ok(!util.isDynamicPattern('@(a|'));
assert.ok(!util.isDynamicPattern('@(a|b'));
});

it('should return false for unfinished brace expansions', () => {
assert.ok(!util.isDynamicPattern('{'));
assert.ok(!util.isDynamicPattern('{'.repeat(999999)));
assert.ok(!util.isDynamicPattern('{a'));
assert.ok(!util.isDynamicPattern('{,'));
assert.ok(!util.isDynamicPattern('{a,'));
assert.ok(!util.isDynamicPattern('{a,b'));
assert.ok(!util.isDynamicPattern('{a' + ','.repeat(999999) + 'b'));
assert.ok(!util.isDynamicPattern('{1..'));
assert.ok(!util.isDynamicPattern('{1.' + '.'.repeat(999999) + '2'));
});
});

Expand Down
4 changes: 2 additions & 2 deletions src/utils/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const ESCAPE_SYMBOL = '\\';
const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\(.*\)/;
const BRACE_EXPANSIONS_SYMBOLS_RE = /{.*(?:,|\.\.).*}/;
const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
const BRACE_EXPANSIONS_SYMBOLS_RE = /{[^,.{]*(?:,|\.\.)[^,.{]*}/;

type PatternTypeOptions = {
braceExpansion?: boolean;
Expand Down

0 comments on commit 9b41dbd

Please sign in to comment.