@riocrypto/common-server 1.0.1908 → 1.0.1909

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.
@@ -6,15 +6,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.sendWithXSSGuard = void 0;
7
7
  const xss_1 = __importDefault(require("xss"));
8
8
  function sendWithXSSGuard(res, data, statusCode) {
9
- const sanitize = (input) => {
9
+ const sanitize = (input, depth = 0) => {
10
+ const MAX_DEPTH = 1000;
11
+ if (depth > MAX_DEPTH) {
12
+ throw new Error("Maximum recursion depth exceeded");
13
+ }
10
14
  if (typeof input === "string") {
11
15
  return (0, xss_1.default)(input);
12
16
  }
17
+ else if (Array.isArray(input)) {
18
+ return input.map((item) => sanitize(item, depth + 1));
19
+ }
13
20
  else if (typeof input === "object" && input !== null) {
14
21
  const sanitizedObject = {};
15
22
  for (const key in input) {
16
- if (input.hasOwnProperty(key)) {
17
- sanitizedObject[key] = sanitize(input[key]);
23
+ if (Object.prototype.hasOwnProperty.call(input, key)) {
24
+ sanitizedObject[key] = sanitize(input[key], depth + 1);
18
25
  }
19
26
  }
20
27
  return sanitizedObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1908",
3
+ "version": "1.0.1909",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",