Skip to content

Commit 838ce76

Browse files
committed
Fix prototype pollution vuln in pattern caches (fixes #362)
1 parent 4b4428c commit 838ce76

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/xregexp.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const features = {
2525
// Storage for fixed/extended native methods
2626
const fixed = {};
2727
// Storage for regexes cached by `XRegExp.cache`
28-
let regexCache = {};
28+
let regexCache = Object.create(null);
2929
// Storage for pattern details cached by the `XRegExp` constructor
30-
let patternCache = {};
30+
let patternCache = Object.create(null);
3131
// Storage for regex syntax tokens added internally or by `XRegExp.addToken`
3232
const tokens = [];
3333
// Token scopes
@@ -774,10 +774,10 @@ XRegExp.cache = (pattern, flags) => {
774774
XRegExp.cache.flush = (cacheName) => {
775775
if (cacheName === 'patterns') {
776776
// Flush the pattern cache used by the `XRegExp` constructor
777-
patternCache = {};
777+
patternCache = Object.create(null);
778778
} else {
779779
// Flush the regex cache populated by `XRegExp.cache`
780-
regexCache = {};
780+
regexCache = Object.create(null);
781781
}
782782
};
783783

0 commit comments

Comments
 (0)