protobufjs 7.5.7 → 7.5.8

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v7.5.7 (c) 2016, daniel wirtz
3
- * compiled sat, 09 may 2026 05:45:39 utc
2
+ * protobuf.js v7.5.8 (c) 2016, daniel wirtz
3
+ * compiled tue, 12 may 2026 09:39:59 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -2985,11 +2985,13 @@ var Type, // cyclic
2985
2985
  * @function
2986
2986
  * @param {string} name Namespace name
2987
2987
  * @param {Object.<string,*>} json JSON object
2988
+ * @param {number} [depth] Current nesting depth, defaults to `0`
2988
2989
  * @returns {Namespace} Created namespace
2989
2990
  * @throws {TypeError} If arguments are invalid
2990
2991
  */
2991
- Namespace.fromJSON = function fromJSON(name, json) {
2992
- return new Namespace(name, json.options).addJSON(json.nested);
2992
+ Namespace.fromJSON = function fromJSON(name, json, depth) {
2993
+ depth = util.checkDepth(depth);
2994
+ return new Namespace(name, json.options).addJSON(json.nested, depth);
2993
2995
  };
2994
2996
 
2995
2997
  /**
@@ -3147,9 +3149,11 @@ Namespace.prototype.toJSON = function toJSON(toJSONOptions) {
3147
3149
  /**
3148
3150
  * Adds nested objects to this namespace from nested object descriptors.
3149
3151
  * @param {Object.<string,AnyNestedObject>} nestedJson Any nested object descriptors
3152
+ * @param {number} [depth] Current nesting depth, defaults to `0`
3150
3153
  * @returns {Namespace} `this`
3151
3154
  */
3152
- Namespace.prototype.addJSON = function addJSON(nestedJson) {
3155
+ Namespace.prototype.addJSON = function addJSON(nestedJson, depth) {
3156
+ depth = util.checkDepth(depth);
3153
3157
  var ns = this;
3154
3158
  /* istanbul ignore else */
3155
3159
  if (nestedJson) {
@@ -3164,7 +3168,7 @@ Namespace.prototype.addJSON = function addJSON(nestedJson) {
3164
3168
  ? Service.fromJSON
3165
3169
  : nested.id !== undefined
3166
3170
  ? Field.fromJSON
3167
- : Namespace.fromJSON )(names[i], nested)
3171
+ : Namespace.fromJSON )(names[i], nested, depth + 1)
3168
3172
  );
3169
3173
  }
3170
3174
  }
@@ -4654,14 +4658,16 @@ function Root(options) {
4654
4658
  * Loads a namespace descriptor into a root namespace.
4655
4659
  * @param {INamespace} json Namespace descriptor
4656
4660
  * @param {Root} [root] Root namespace, defaults to create a new one if omitted
4661
+ * @param {number} [depth] Current nesting depth, defaults to `0`
4657
4662
  * @returns {Root} Root namespace
4658
4663
  */
4659
- Root.fromJSON = function fromJSON(json, root) {
4664
+ Root.fromJSON = function fromJSON(json, root, depth) {
4665
+ depth = util.checkDepth(depth);
4660
4666
  if (!root)
4661
4667
  root = new Root();
4662
4668
  if (json.options)
4663
4669
  root.setOptions(json.options);
4664
- return root.addJSON(json.nested).resolveAll();
4670
+ return root.addJSON(json.nested, depth).resolveAll();
4665
4671
  };
4666
4672
 
4667
4673
  /**
@@ -5255,17 +5261,19 @@ function Service(name, options) {
5255
5261
  * Constructs a service from a service descriptor.
5256
5262
  * @param {string} name Service name
5257
5263
  * @param {IService} json Service descriptor
5264
+ * @param {number} [depth] Current nesting depth, defaults to `0`
5258
5265
  * @returns {Service} Created service
5259
5266
  * @throws {TypeError} If arguments are invalid
5260
5267
  */
5261
- Service.fromJSON = function fromJSON(name, json) {
5268
+ Service.fromJSON = function fromJSON(name, json, depth) {
5269
+ depth = util.checkDepth(depth);
5262
5270
  var service = new Service(name, json.options);
5263
5271
  /* istanbul ignore else */
5264
5272
  if (json.methods)
5265
5273
  for (var names = Object.keys(json.methods), i = 0; i < names.length; ++i)
5266
5274
  service.add(Method.fromJSON(names[i], json.methods[names[i]]));
5267
5275
  if (json.nested)
5268
- service.addJSON(json.nested);
5276
+ service.addJSON(json.nested, depth);
5269
5277
  if (json.edition)
5270
5278
  service._edition = json.edition;
5271
5279
  service.comment = json.comment;
@@ -5635,9 +5643,11 @@ function clearCache(type) {
5635
5643
  * Creates a message type from a message type descriptor.
5636
5644
  * @param {string} name Message name
5637
5645
  * @param {IType} json Message type descriptor
5646
+ * @param {number} [depth] Current nesting depth, defaults to `0`
5638
5647
  * @returns {Type} Created message type
5639
5648
  */
5640
- Type.fromJSON = function fromJSON(name, json) {
5649
+ Type.fromJSON = function fromJSON(name, json, depth) {
5650
+ depth = util.checkDepth(depth);
5641
5651
  var type = new Type(name, json.options);
5642
5652
  type.extensions = json.extensions;
5643
5653
  type.reserved = json.reserved;
@@ -5664,7 +5674,7 @@ Type.fromJSON = function fromJSON(name, json) {
5664
5674
  ? Enum.fromJSON
5665
5675
  : nested.methods !== undefined
5666
5676
  ? Service.fromJSON
5667
- : Namespace.fromJSON )(names[i], nested)
5677
+ : Namespace.fromJSON )(names[i], nested, depth + 1)
5668
5678
  );
5669
5679
  }
5670
5680
  if (json.extensions && json.extensions.length)
@@ -6252,6 +6262,20 @@ var reservedRe = util.patterns.reservedRe,
6252
6262
  */
6253
6263
  util.fs = util.inquire("fs");
6254
6264
 
6265
+ /**
6266
+ * Checks a recursion depth.
6267
+ * @param {number|undefined} depth Depth of recursion
6268
+ * @returns {number} Depth of recursion
6269
+ * @throws {Error} If depth exceeds util.recursionLimit
6270
+ */
6271
+ util.checkDepth = function checkDepth(depth) {
6272
+ if (depth === undefined)
6273
+ depth = 0;
6274
+ if (depth > util.recursionLimit)
6275
+ throw Error("max depth exceeded");
6276
+ return depth;
6277
+ };
6278
+
6255
6279
  /**
6256
6280
  * Converts an object's values to an array.
6257
6281
  * @param {Object.<string,*>} object Object to convert