mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Reset the state of regex in minimongo on matching
Fixes #2817. Regular Expressions in JavaScript keep the state when matching for the same string. When there are two documents with the same value of the matching field, the minimongo can incorrectly filter collection because regexp would return different values on different calls.
This commit is contained in:
@@ -214,6 +214,11 @@ regexpElementMatcher = function (regexp) {
|
||||
// Regexps only work against strings.
|
||||
if (typeof value !== 'string')
|
||||
return false;
|
||||
|
||||
// reset regexp's state to avoid inconsistent matching for objects with the
|
||||
// same value on consecutive calls of regexp.test
|
||||
regexp.lastIndex = 0;
|
||||
|
||||
return regexp.test(value);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user