alasql 4.10.1 → 4.10.3

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.
package/bin/alasql-cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  //
4
4
  // Command line interface for Alasql
5
- // Version: 0.2.3
5
+ // Version: 4.10.3
6
6
  // Date: 28.07.2015
7
7
  // (c) 2014-2022, Andrey Gershun & Mathias Wulff
8
8
  //
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.10.0 build: develop-4b9a20d8 | © 2014-2025 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.10.3 build: develop-4b9a20d8 | © 2014-2025 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.10.0
4
+ @version 4.10.3
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2025 Andrey Gershun & Mathias Wulff
package/dist/alasql.fs.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.10.0 build: develop-4b9a20d8 | © 2014-2025 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.10.3 build: develop-4b9a20d8 | © 2014-2025 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.10.0
4
+ @version 4.10.3
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2025 Andrey Gershun & Mathias Wulff
@@ -141,7 +141,7 @@ SOFTWARE.
141
141
  Current version of alasql
142
142
  @constant {string}
143
143
  */
144
- alasql.version = '4.10.0';
144
+ alasql.version = '4.10.3';
145
145
  alasql.build = 'develop-4b9a20d8';
146
146
 
147
147
  /**
@@ -2540,7 +2540,7 @@ next:function () {
2540
2540
 
2541
2541
  // return next match that has a token
2542
2542
  lex:function lex () {
2543
- var r = this.next();
2543
+ var r = this.next();if(r&&/^(N?['"]__proto__['"]|\[__proto__\]|`__proto__`|__proto__)$/i.test(this.yytext))throw new Error("__proto__ is not allowed");
2544
2544
  if (r) {
2545
2545
  return r;
2546
2546
  } else {
@@ -4096,11 +4096,11 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
4096
4096
  return +obj;
4097
4097
  }
4098
4098
 
4099
- var temp = new obj.constructor(); // changed
4099
+ var temp = new (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
4100
4100
 
4101
4101
  for (var key in obj) {
4102
4102
  if (obj.hasOwnProperty(key)) {
4103
- temp[key] = cloneDeep(obj[key]);
4103
+ /* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(temp, key, {value: cloneDeep(obj[key]), writable: true, enumerable: true, configurable: true}); } else { temp[key] = cloneDeep(obj[key]); }
4104
4104
  }
4105
4105
  }
4106
4106
  return temp;
@@ -4172,7 +4172,7 @@ var extend = (utils.extend = function extend(a, b) {
4172
4172
  a = a || {};
4173
4173
  for (var key in b) {
4174
4174
  if (b.hasOwnProperty(key)) {
4175
- a[key] = b[key];
4175
+ /* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(a, key, {value: b[key], writable: true, enumerable: true, configurable: true}); } else { a[key] = b[key]; }
4176
4176
  }
4177
4177
  }
4178
4178
  return a;
@@ -6610,7 +6610,7 @@ function queryfn3(query) {
6610
6610
 
6611
6611
  // Prepare variables
6612
6612
  query.data = [];
6613
- query.xgroups = {};
6613
+ query.xgroups=Object.create(null);
6614
6614
  query.groups = [];
6615
6615
 
6616
6616
  // Level of Joins
@@ -8558,7 +8558,7 @@ yy.Select.prototype.compileGroup = function (query) {
8558
8558
  aft2 = '';
8559
8559
 
8560
8560
  if (typeof query.groupStar !== 'undefined') {
8561
- aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
8561
+ aft2 += "for(var f in p['" + query.groupStar + "']) {if(/^__proto__$/.test(f))Object.defineProperty(g,f,{writable:true,enumerable:true,configurable:true});g[f]=p['" + query.groupStar + "'][f];};";
8562
8562
  }
8563
8563
 
8564
8564
  s += query.selectGroup
@@ -9007,7 +9007,7 @@ function compileSelectStar(query, aliases, joinstar) {
9007
9007
  } else {
9008
9008
 
9009
9009
  // if column not exist, then copy all
9010
- sp += 'var w=p["' + alias + '"];for(var k in w){r[k]=w[k]};';
9010
+ sp += 'var w=p["' + alias + '"];for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
9011
9011
 
9012
9012
  query.dirtyColumns = true;
9013
9013
  }
@@ -9362,10 +9362,10 @@ yy.Select.prototype.compileSelectGroup1 = function (query) {
9362
9362
  self.columns.forEach(function (col) {
9363
9363
 
9364
9364
  if (col instanceof yy.Column && col.columnid === '*') {
9365
- // s += 'for(var k in g){r[k]=g[k]};';
9365
+ // s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9366
9366
  // s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
9367
9367
 
9368
- s += 'for(var k in g) {r[k]=g[k]};';
9368
+ s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9369
9369
  return '';
9370
9370
 
9371
9371
  } else {
@@ -10633,7 +10633,7 @@ yy.Over = class Over {
10633
10633
  const allValues = this.right.map(value => value.value);
10634
10634
  const allValuesStr = allValues.join(',');
10635
10635
  alasql.sets[allValuesStr] = alasql.sets[allValuesStr] || new Set(allValues);
10636
- s = `alasql.sets["${allValuesStr}"].has(alasql.utils.getValueOf(${leftJS()}))`;
10636
+ s = `alasql.sets[${JSON.stringify(allValuesStr)}].has(alasql.utils.getValueOf(${leftJS()}))`;
10637
10637
  }
10638
10638
  } else {
10639
10639
  s = `(${rightJS()}.indexOf(${leftJS()}) > -1)`;
@@ -10651,7 +10651,7 @@ yy.Over = class Over {
10651
10651
  const allValues = this.right.map(value => value.value);
10652
10652
  const allValuesStr = allValues.join(',');
10653
10653
  alasql.sets[allValuesStr] = alasql.sets[allValuesStr] || new Set(allValues);
10654
- s = `!alasql.sets["${allValuesStr}"].has(alasql.utils.getValueOf(${leftJS()}))`;
10654
+ s = `!alasql.sets[${JSON.stringify(allValuesStr)}].has(alasql.utils.getValueOf(${leftJS()}))`;
10655
10655
  }
10656
10656
  } else {
10657
10657
  s = `(${rightJS()}.indexOf(${leftJS()}) === -1)`;
@@ -12534,7 +12534,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12534
12534
 
12535
12535
  table.update(
12536
12536
  function (t) {
12537
- for (var f in r) t[f] = r[f];
12537
+ for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
12538
12538
  },
12539
12539
  table.data.indexOf(toreplace),
12540
12540
  params
@@ -14092,7 +14092,7 @@ yy.Insert.prototype.compile = function (databaseid) {
14092
14092
  });
14093
14093
  } else {
14094
14094
 
14095
- // sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
14095
+ // sw = 'var w='+JSONtoJS(values)+';for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
14096
14096
  sw = JSONtoJS(values);
14097
14097
  }
14098
14098
  }
@@ -15127,22 +15127,22 @@ yy.SetVariable.prototype.execute = function (databaseid, params, cb) {
15127
15127
  if (this.props && this.props.length > 0) {
15128
15128
  let fs;
15129
15129
  if (this.method === '@') {
15130
- fs = `alasql.vars['${this.variable}']`;
15130
+ fs = `alasql.vars[k('${this.variable}')]`;
15131
15131
  } else {
15132
- fs = `params['${this.variable}']`;
15132
+ fs = `params[k('${this.variable}')]`;
15133
15133
  }
15134
15134
  this.props.forEach(prop => {
15135
15135
  if (typeof prop === 'string') {
15136
- fs += `['${prop}']`;
15136
+ fs += `[k('${prop}')]`;
15137
15137
  } else if (typeof prop === 'number') {
15138
15138
  fs += `[${prop}]`;
15139
15139
  } else {
15140
15140
  // Assuming prop.toJS() is a method that converts prop to a JavaScript expression.
15141
- fs += `[${prop.toJS()}]`;
15141
+ fs += `[k(${prop.toJS()})]`;
15142
15142
  }
15143
15143
  });
15144
15144
 
15145
- new Function('value, params, alasql', `${fs} = value`)(res, params, alasql);
15145
+ new Function('value, params, alasql', `var k=function(x){if(x==="__proto__"||x==="constructor"||x==="prototype")throw new Error(x+" is not allowed");return x};${fs} = value`)(res, params, alasql);
15146
15146
  } else {
15147
15147
  if (this.method === '@') {
15148
15148
  alasql.vars[this.variable] = res;
package/dist/alasql.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.10.0 build: develop-4b9a20d8 | © 2014-2025 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.10.3 build: develop-4b9a20d8 | © 2014-2025 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.10.0
4
+ @version 4.10.3
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2025 Andrey Gershun & Mathias Wulff
@@ -141,7 +141,7 @@ SOFTWARE.
141
141
  Current version of alasql
142
142
  @constant {string}
143
143
  */
144
- alasql.version = '4.10.0';
144
+ alasql.version = '4.10.3';
145
145
  alasql.build = 'develop-4b9a20d8';
146
146
 
147
147
  /**
@@ -2540,7 +2540,7 @@ next:function () {
2540
2540
 
2541
2541
  // return next match that has a token
2542
2542
  lex:function lex () {
2543
- var r = this.next();
2543
+ var r = this.next();if(r&&/^(N?['"]__proto__['"]|\[__proto__\]|`__proto__`|__proto__)$/i.test(this.yytext))throw new Error("__proto__ is not allowed");
2544
2544
  if (r) {
2545
2545
  return r;
2546
2546
  } else {
@@ -4096,11 +4096,11 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
4096
4096
  return +obj;
4097
4097
  }
4098
4098
 
4099
- var temp = new obj.constructor(); // changed
4099
+ var temp = new (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
4100
4100
 
4101
4101
  for (var key in obj) {
4102
4102
  if (obj.hasOwnProperty(key)) {
4103
- temp[key] = cloneDeep(obj[key]);
4103
+ /* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(temp, key, {value: cloneDeep(obj[key]), writable: true, enumerable: true, configurable: true}); } else { temp[key] = cloneDeep(obj[key]); }
4104
4104
  }
4105
4105
  }
4106
4106
  return temp;
@@ -4172,7 +4172,7 @@ var extend = (utils.extend = function extend(a, b) {
4172
4172
  a = a || {};
4173
4173
  for (var key in b) {
4174
4174
  if (b.hasOwnProperty(key)) {
4175
- a[key] = b[key];
4175
+ /* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(a, key, {value: b[key], writable: true, enumerable: true, configurable: true}); } else { a[key] = b[key]; }
4176
4176
  }
4177
4177
  }
4178
4178
  return a;
@@ -6610,7 +6610,7 @@ function queryfn3(query) {
6610
6610
 
6611
6611
  // Prepare variables
6612
6612
  query.data = [];
6613
- query.xgroups = {};
6613
+ query.xgroups=Object.create(null);
6614
6614
  query.groups = [];
6615
6615
 
6616
6616
  // Level of Joins
@@ -8558,7 +8558,7 @@ yy.Select.prototype.compileGroup = function (query) {
8558
8558
  aft2 = '';
8559
8559
 
8560
8560
  if (typeof query.groupStar !== 'undefined') {
8561
- aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
8561
+ aft2 += "for(var f in p['" + query.groupStar + "']) {if(/^__proto__$/.test(f))Object.defineProperty(g,f,{writable:true,enumerable:true,configurable:true});g[f]=p['" + query.groupStar + "'][f];};";
8562
8562
  }
8563
8563
 
8564
8564
  s += query.selectGroup
@@ -9007,7 +9007,7 @@ function compileSelectStar(query, aliases, joinstar) {
9007
9007
  } else {
9008
9008
 
9009
9009
  // if column not exist, then copy all
9010
- sp += 'var w=p["' + alias + '"];for(var k in w){r[k]=w[k]};';
9010
+ sp += 'var w=p["' + alias + '"];for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
9011
9011
 
9012
9012
  query.dirtyColumns = true;
9013
9013
  }
@@ -9362,10 +9362,10 @@ yy.Select.prototype.compileSelectGroup1 = function (query) {
9362
9362
  self.columns.forEach(function (col) {
9363
9363
 
9364
9364
  if (col instanceof yy.Column && col.columnid === '*') {
9365
- // s += 'for(var k in g){r[k]=g[k]};';
9365
+ // s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9366
9366
  // s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
9367
9367
 
9368
- s += 'for(var k in g) {r[k]=g[k]};';
9368
+ s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9369
9369
  return '';
9370
9370
 
9371
9371
  } else {
@@ -10633,7 +10633,7 @@ yy.Over = class Over {
10633
10633
  const allValues = this.right.map(value => value.value);
10634
10634
  const allValuesStr = allValues.join(',');
10635
10635
  alasql.sets[allValuesStr] = alasql.sets[allValuesStr] || new Set(allValues);
10636
- s = `alasql.sets["${allValuesStr}"].has(alasql.utils.getValueOf(${leftJS()}))`;
10636
+ s = `alasql.sets[${JSON.stringify(allValuesStr)}].has(alasql.utils.getValueOf(${leftJS()}))`;
10637
10637
  }
10638
10638
  } else {
10639
10639
  s = `(${rightJS()}.indexOf(${leftJS()}) > -1)`;
@@ -10651,7 +10651,7 @@ yy.Over = class Over {
10651
10651
  const allValues = this.right.map(value => value.value);
10652
10652
  const allValuesStr = allValues.join(',');
10653
10653
  alasql.sets[allValuesStr] = alasql.sets[allValuesStr] || new Set(allValues);
10654
- s = `!alasql.sets["${allValuesStr}"].has(alasql.utils.getValueOf(${leftJS()}))`;
10654
+ s = `!alasql.sets[${JSON.stringify(allValuesStr)}].has(alasql.utils.getValueOf(${leftJS()}))`;
10655
10655
  }
10656
10656
  } else {
10657
10657
  s = `(${rightJS()}.indexOf(${leftJS()}) === -1)`;
@@ -12534,7 +12534,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12534
12534
 
12535
12535
  table.update(
12536
12536
  function (t) {
12537
- for (var f in r) t[f] = r[f];
12537
+ for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
12538
12538
  },
12539
12539
  table.data.indexOf(toreplace),
12540
12540
  params
@@ -14092,7 +14092,7 @@ yy.Insert.prototype.compile = function (databaseid) {
14092
14092
  });
14093
14093
  } else {
14094
14094
 
14095
- // sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
14095
+ // sw = 'var w='+JSONtoJS(values)+';for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
14096
14096
  sw = JSONtoJS(values);
14097
14097
  }
14098
14098
  }
@@ -15127,22 +15127,22 @@ yy.SetVariable.prototype.execute = function (databaseid, params, cb) {
15127
15127
  if (this.props && this.props.length > 0) {
15128
15128
  let fs;
15129
15129
  if (this.method === '@') {
15130
- fs = `alasql.vars['${this.variable}']`;
15130
+ fs = `alasql.vars[k('${this.variable}')]`;
15131
15131
  } else {
15132
- fs = `params['${this.variable}']`;
15132
+ fs = `params[k('${this.variable}')]`;
15133
15133
  }
15134
15134
  this.props.forEach(prop => {
15135
15135
  if (typeof prop === 'string') {
15136
- fs += `['${prop}']`;
15136
+ fs += `[k('${prop}')]`;
15137
15137
  } else if (typeof prop === 'number') {
15138
15138
  fs += `[${prop}]`;
15139
15139
  } else {
15140
15140
  // Assuming prop.toJS() is a method that converts prop to a JavaScript expression.
15141
- fs += `[${prop.toJS()}]`;
15141
+ fs += `[k(${prop.toJS()})]`;
15142
15142
  }
15143
15143
  });
15144
15144
 
15145
- new Function('value, params, alasql', `${fs} = value`)(res, params, alasql);
15145
+ new Function('value, params, alasql', `var k=function(x){if(x==="__proto__"||x==="constructor"||x==="prototype")throw new Error(x+" is not allowed");return x};${fs} = value`)(res, params, alasql);
15146
15146
  } else {
15147
15147
  if (this.method === '@') {
15148
15148
  alasql.vars[this.variable] = res;