masterrecord 0.3.59 → 0.3.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,12 @@ const LOG_OPERATORS_REGEX = /(\|\|)|(&&)/;
4
4
  var tools = require('../Tools');
5
5
  const QueryParameters = require('./queryParameters');
6
6
 
7
+ // Escape special regex characters so user-supplied names can be safely
8
+ // interpolated into RegExp constructors (prevents "Unmatched ')'" etc.)
9
+ function escapeRegExp(str) {
10
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
11
+ }
12
+
7
13
  class queryScript{
8
14
 
9
15
  constructor(){
@@ -216,12 +222,12 @@ class queryScript{
216
222
  }
217
223
 
218
224
  MATCH_ENTITY_REGEXP(entityName) {
219
- return new RegExp("(^|[^\\w\\d])" + entityName + "[ \\.\\)]");
225
+ return new RegExp("(^|[^\\w\\d])" + escapeRegExp(entityName) + "[ \\.\\)]");
220
226
  }
221
227
 
222
228
  OPERATORS_REGEX(entityName){
223
229
  // Prefer longest operators first to avoid partially matching '>' in '>=' and leaving '=' in the argument
224
- return new RegExp("(?:^|[^\\w\\d])" + entityName
230
+ return new RegExp("(?:^|[^\\w\\d])" + escapeRegExp(entityName)
225
231
  + "\\.((?:\\.?[\\w\\d_\\$]+)+)(?:\\((.*?)\\))?(?:\\s*((?:===)|(?:!==)|(?:<=)|(?:>=)|(?:==)|(?:!=)|(?:in)|>|<|(?:=))\\s*(.*))?")
226
232
  }
227
233
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "masterrecord",
3
- "version": "0.3.59",
3
+ "version": "0.3.60",
4
4
  "description": "An Object-relational mapping for the Master framework. Master Record connects classes to relational database tables to establish a database with almost zero-configuration ",
5
5
  "main": "MasterRecord.js",
6
6
  "bin": {