@aemforms/af-core 0.22.153 → 0.22.155

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.
@@ -1037,6 +1037,13 @@ const replaceTemplatePlaceholders = (str, values = []) => {
1037
1037
  return typeof replacement !== 'undefined' ? replacement : match;
1038
1038
  });
1039
1039
  };
1040
+ const sanitizeName = (name) => {
1041
+ const nameRegex = /^[A-Za-z_$][A-Za-z0-9_.]*$/;
1042
+ if (!nameRegex.test(name)) {
1043
+ return `"${name}"`;
1044
+ }
1045
+ return name;
1046
+ };
1040
1047
 
1041
1048
  const dateRegex = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
1042
1049
  const emailRegex = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
@@ -1936,7 +1943,8 @@ class Scriptable extends BaseNode {
1936
1943
  try {
1937
1944
  let updatedRule = eString;
1938
1945
  if (this.fragment !== '$form') {
1939
- updatedRule = eString.replaceAll('$form', this.fragment);
1946
+ const sanitizedFragment = sanitizeName(this.fragment);
1947
+ updatedRule = eString.replaceAll('$form', sanitizedFragment);
1940
1948
  }
1941
1949
  this._rules[eName] = this.ruleEngine.compileRule(updatedRule, this.lang);
1942
1950
  }
@@ -1961,7 +1969,8 @@ class Scriptable extends BaseNode {
1961
1969
  try {
1962
1970
  let updatedExpr = x;
1963
1971
  if (this.fragment !== '$form') {
1964
- updatedExpr = x.replaceAll('$form', this.fragment);
1972
+ const sanitizedFragment = sanitizeName(this.fragment);
1973
+ updatedExpr = x.replaceAll('$form', sanitizedFragment);
1965
1974
  }
1966
1975
  return this.ruleEngine.compileRule(updatedExpr, this.lang);
1967
1976
  }
@@ -3257,13 +3266,17 @@ class FunctionRuntimeImpl {
3257
3266
  getData: {
3258
3267
  _func: (args, data, interpreter) => {
3259
3268
  interpreter.globals.form.logger.warn('The `getData` function is depricated. Use `exportData` instead.');
3260
- return interpreter.globals.form.exportData();
3269
+ return interpreter.globals.form.withDependencyTrackingControl(true, () => {
3270
+ return interpreter.globals.form.exportData();
3271
+ });
3261
3272
  },
3262
3273
  _signature: []
3263
3274
  },
3264
3275
  exportData: {
3265
3276
  _func: (args, data, interpreter) => {
3266
- return interpreter.globals.form.exportData();
3277
+ return interpreter.globals.form.withDependencyTrackingControl(true, () => {
3278
+ return interpreter.globals.form.exportData();
3279
+ });
3267
3280
  },
3268
3281
  _signature: []
3269
3282
  },
@@ -5,7 +5,7 @@ export * from './utils/TranslationUtils';
5
5
  export * from './utils/JsonUtils';
6
6
  export * from './utils/SchemaUtils';
7
7
  export * from './Constant';
8
- import { getFileSizeInBytes, extractFileInfo, isEmpty, readAttachments } from './utils/FormUtils';
8
+ import { getFileSizeInBytes, extractFileInfo, isEmpty, readAttachments, sanitizeName } from './utils/FormUtils';
9
9
  import { BaseNode } from './BaseNode';
10
10
  import Checkbox from './Checkbox';
11
11
  import CheckboxGroup from './CheckboxGroup';
@@ -22,4 +22,4 @@ import Node from './Node';
22
22
  import Scriptable from './Scriptable';
23
23
  import Form from './Form';
24
24
  import { FunctionRuntime, request } from './rules/FunctionRuntime';
25
- export { Form, BaseNode, Checkbox, CheckboxGroup, Container, Field, Fieldset, FileObject, FileUpload, FormMetaData, Node, Scriptable, getFileSizeInBytes, extractFileInfo, readAttachments, FunctionRuntime, request, isEmpty, SubmitMetaData, EmailInput, Captcha };
25
+ export { Form, BaseNode, Checkbox, CheckboxGroup, Container, Field, Fieldset, FileObject, FileUpload, FormMetaData, Node, Scriptable, getFileSizeInBytes, extractFileInfo, readAttachments, FunctionRuntime, request, isEmpty, SubmitMetaData, EmailInput, Captcha, sanitizeName };
@@ -13,3 +13,4 @@ export declare const dataURItoBlob: (dataURI: string) => {
13
13
  } | null;
14
14
  export declare const sitesModelToFormModel: (sitesModel: any) => any;
15
15
  export declare const replaceTemplatePlaceholders: (str: string, values?: any[]) => string;
16
+ export declare const sanitizeName: (name: string) => string;
package/lib/Scriptable.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const BaseNode_1 = require("./BaseNode");
4
+ const FormUtils_1 = require("./utils/FormUtils");
4
5
  class Scriptable extends BaseNode_1.BaseNode {
5
6
  constructor() {
6
7
  super(...arguments);
@@ -17,7 +18,8 @@ class Scriptable extends BaseNode_1.BaseNode {
17
18
  try {
18
19
  let updatedRule = eString;
19
20
  if (this.fragment !== '$form') {
20
- updatedRule = eString.replaceAll('$form', this.fragment);
21
+ const sanitizedFragment = (0, FormUtils_1.sanitizeName)(this.fragment);
22
+ updatedRule = eString.replaceAll('$form', sanitizedFragment);
21
23
  }
22
24
  this._rules[eName] = this.ruleEngine.compileRule(updatedRule, this.lang);
23
25
  }
@@ -43,7 +45,8 @@ class Scriptable extends BaseNode_1.BaseNode {
43
45
  try {
44
46
  let updatedExpr = x;
45
47
  if (this.fragment !== '$form') {
46
- updatedExpr = x.replaceAll('$form', this.fragment);
48
+ const sanitizedFragment = (0, FormUtils_1.sanitizeName)(this.fragment);
49
+ updatedExpr = x.replaceAll('$form', sanitizedFragment);
47
50
  }
48
51
  return this.ruleEngine.compileRule(updatedExpr, this.lang);
49
52
  }
package/lib/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export * from './utils/TranslationUtils';
5
5
  export * from './utils/JsonUtils';
6
6
  export * from './utils/SchemaUtils';
7
7
  export * from './Constant';
8
- import { getFileSizeInBytes, extractFileInfo, isEmpty, readAttachments } from './utils/FormUtils';
8
+ import { getFileSizeInBytes, extractFileInfo, isEmpty, readAttachments, sanitizeName } from './utils/FormUtils';
9
9
  import { BaseNode } from './BaseNode';
10
10
  import Checkbox from './Checkbox';
11
11
  import CheckboxGroup from './CheckboxGroup';
@@ -22,4 +22,4 @@ import Node from './Node';
22
22
  import Scriptable from './Scriptable';
23
23
  import Form from './Form';
24
24
  import { FunctionRuntime, request } from './rules/FunctionRuntime';
25
- export { Form, BaseNode, Checkbox, CheckboxGroup, Container, Field, Fieldset, FileObject, FileUpload, FormMetaData, Node, Scriptable, getFileSizeInBytes, extractFileInfo, readAttachments, FunctionRuntime, request, isEmpty, SubmitMetaData, EmailInput, Captcha };
25
+ export { Form, BaseNode, Checkbox, CheckboxGroup, Container, Field, Fieldset, FileObject, FileUpload, FormMetaData, Node, Scriptable, getFileSizeInBytes, extractFileInfo, readAttachments, FunctionRuntime, request, isEmpty, SubmitMetaData, EmailInput, Captcha, sanitizeName };
package/lib/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.Captcha = exports.EmailInput = exports.SubmitMetaData = exports.isEmpty = exports.request = exports.FunctionRuntime = exports.readAttachments = exports.extractFileInfo = exports.getFileSizeInBytes = exports.Scriptable = exports.Node = exports.FormMetaData = exports.FileUpload = exports.FileObject = exports.Fieldset = exports.Field = exports.Container = exports.CheckboxGroup = exports.Checkbox = exports.BaseNode = exports.Form = void 0;
20
+ exports.sanitizeName = exports.Captcha = exports.EmailInput = exports.SubmitMetaData = exports.isEmpty = exports.request = exports.FunctionRuntime = exports.readAttachments = exports.extractFileInfo = exports.getFileSizeInBytes = exports.Scriptable = exports.Node = exports.FormMetaData = exports.FileUpload = exports.FileObject = exports.Fieldset = exports.Field = exports.Container = exports.CheckboxGroup = exports.Checkbox = exports.BaseNode = exports.Form = void 0;
21
21
  __exportStar(require("./FormInstance"), exports);
22
22
  __exportStar(require("./types/index"), exports);
23
23
  __exportStar(require("./controller/Events"), exports);
@@ -30,6 +30,7 @@ Object.defineProperty(exports, "getFileSizeInBytes", { enumerable: true, get: fu
30
30
  Object.defineProperty(exports, "extractFileInfo", { enumerable: true, get: function () { return FormUtils_1.extractFileInfo; } });
31
31
  Object.defineProperty(exports, "isEmpty", { enumerable: true, get: function () { return FormUtils_1.isEmpty; } });
32
32
  Object.defineProperty(exports, "readAttachments", { enumerable: true, get: function () { return FormUtils_1.readAttachments; } });
33
+ Object.defineProperty(exports, "sanitizeName", { enumerable: true, get: function () { return FormUtils_1.sanitizeName; } });
33
34
  const BaseNode_1 = require("./BaseNode");
34
35
  Object.defineProperty(exports, "BaseNode", { enumerable: true, get: function () { return BaseNode_1.BaseNode; } });
35
36
  const Checkbox_1 = __importDefault(require("./Checkbox"));
@@ -408,13 +408,17 @@ class FunctionRuntimeImpl {
408
408
  getData: {
409
409
  _func: (args, data, interpreter) => {
410
410
  interpreter.globals.form.logger.warn('The `getData` function is depricated. Use `exportData` instead.');
411
- return interpreter.globals.form.exportData();
411
+ return interpreter.globals.form.withDependencyTrackingControl(true, () => {
412
+ return interpreter.globals.form.exportData();
413
+ });
412
414
  },
413
415
  _signature: []
414
416
  },
415
417
  exportData: {
416
418
  _func: (args, data, interpreter) => {
417
- return interpreter.globals.form.exportData();
419
+ return interpreter.globals.form.withDependencyTrackingControl(true, () => {
420
+ return interpreter.globals.form.exportData();
421
+ });
418
422
  },
419
423
  _signature: []
420
424
  },
@@ -13,3 +13,4 @@ export declare const dataURItoBlob: (dataURI: string) => {
13
13
  } | null;
14
14
  export declare const sitesModelToFormModel: (sitesModel: any) => any;
15
15
  export declare const replaceTemplatePlaceholders: (str: string, values?: any[]) => string;
16
+ export declare const sanitizeName: (name: string) => string;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.replaceTemplatePlaceholders = exports.sitesModelToFormModel = exports.dataURItoBlob = exports.extractFileInfo = exports.isDataUrl = exports.IdGenerator = exports.getFileSizeInBytes = exports.getAttachments = exports.readAttachments = exports.isEmpty = exports.randomWord = void 0;
12
+ exports.sanitizeName = exports.replaceTemplatePlaceholders = exports.sitesModelToFormModel = exports.dataURItoBlob = exports.extractFileInfo = exports.isDataUrl = exports.IdGenerator = exports.getFileSizeInBytes = exports.getAttachments = exports.readAttachments = exports.isEmpty = exports.randomWord = void 0;
13
13
  const JsonUtils_1 = require("./JsonUtils");
14
14
  const FileObject_1 = require("../FileObject");
15
15
  const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'.split('');
@@ -285,3 +285,11 @@ const replaceTemplatePlaceholders = (str, values = []) => {
285
285
  });
286
286
  };
287
287
  exports.replaceTemplatePlaceholders = replaceTemplatePlaceholders;
288
+ const sanitizeName = (name) => {
289
+ const nameRegex = /^[A-Za-z_$][A-Za-z0-9_.]*$/;
290
+ if (!nameRegex.test(name)) {
291
+ return `"${name}"`;
292
+ }
293
+ return name;
294
+ };
295
+ exports.sanitizeName = sanitizeName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.153",
3
+ "version": "0.22.155",
4
4
  "description": "Core Module for Forms Runtime",
5
5
  "author": "Adobe Systems",
6
6
  "license": "Adobe Proprietary",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@adobe/json-formula": "0.1.50",
40
- "@aemforms/af-formatters": "^0.22.153"
40
+ "@aemforms/af-formatters": "^0.22.155"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",