Skip to content

Commit cc76152

Browse files
Merge pull request #144 from Jason3S/jdent-object-properties
fix: exception when glob pattern contains `constructor`
2 parents bf6a33b + 94e3438 commit cc76152

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ module.exports = {
9999

100100
// Replace globs with equivalent patterns to reduce parsing time.
101101
REPLACEMENTS: {
102+
__proto__: null,
102103
'***': '*',
103104
'**/**': '**',
104105
'**/**/**': '**'

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)