We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6cca835 commit 64dcd48Copy full SHA for 64dcd48
src/models/eventsFactory.js
@@ -1,5 +1,6 @@
1
import { getMidnightWithTimezoneOffset, getUTCMidnight } from '../utils/dates';
2
import { groupBy } from '../utils/grouper';
3
+import safe from 'safe-regex';
4
5
const Factory = require('./modelFactory');
6
const mongo = require('../mongo');
@@ -164,6 +165,13 @@ class EventsFactory extends Factory {
164
165
throw new Error('Search parameter must be a string');
166
}
167
168
+ /**
169
+ * Check if pattern is safe RegExp
170
+ */
171
+ if (!safe(search)) {
172
+ throw new Error('Invalid regular expression pattern');
173
+ }
174
+
175
const escapedSearch = search.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
176
177
limit = this.validateLimit(limit);
0 commit comments