Skip to content

Commit fc1f6b6

Browse files
committed
Merge commit from fork
1 parent eec17ae commit fc1f6b6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const WINDOWS_CHARS = {
6969
*/
7070

7171
const POSIX_REGEX_SOURCE = {
72+
__proto__: null,
7273
alnum: 'a-zA-Z0-9',
7374
alpha: 'a-zA-Z',
7475
ascii: '\\x00-\\x7F',

test/malicious.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const assert = require('assert');
4-
const { isMatch } = require('..');
4+
const { isMatch, makeRe } = require('..');
55
const repeat = n => '\\'.repeat(n);
66

77
/**
@@ -30,9 +30,16 @@ 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+
3334
it('should be able to accept Object instance properties', () => {
3435
assert(isMatch('constructor', 'constructor'), 'valid match');
3536
assert(isMatch('__proto__', '__proto__'), 'valid match');
3637
assert(isMatch('toString', 'toString'), 'valid match');
3738
});
39+
40+
it('should not expose internal prototype properties', () => {
41+
assert.equal(makeRe('[[:constructor:]]').toString(), '/^(?:[[:constructor:]\\])$/');
42+
assert(!isMatch('f }]', '[[:constructor:]]'), 'not valid match');
43+
assert(!isMatch('a }]', '[[:constructor:]]'), 'not valid match');
44+
});
3845
});

0 commit comments

Comments
 (0)