Skip to content

Commit a9e2dd2

Browse files
committed
fix: exception when glob pattern contains constructor
1 parent bf6a33b commit a9e2dd2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ module.exports = {
9898
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
9999

100100
// Replace globs with equivalent patterns to reduce parsing time.
101-
REPLACEMENTS: {
101+
REPLACEMENTS: Object.assign(Object.create(null), {
102102
'***': '*',
103103
'**/**': '**',
104104
'**/**/**': '**'
105-
},
105+
}),
106106

107107
// Digits
108108
CHAR_0: 48, /* 0 */

test/malicious.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ describe('handling of potential regex exploits', () => {
3030
assert(!isMatch('A', `!(${repeat(500)}A)`, { maxLength: 499 }));
3131
}, /Input length: 504, exceeds maximum allowed length: 499/);
3232
});
33+
it('should be able to accept Object instance properties', () => {
34+
assert(isMatch('constructor', 'constructor'), 'valid match');
35+
assert(isMatch('__proto__', '__proto__'), 'valid match');
36+
assert(isMatch('toString', 'toString'), 'valid match');
37+
});
3338
});

0 commit comments

Comments
 (0)