protobufjs 8.4.1 → 8.4.2

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/dist/protobuf.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v8.4.1 (c) 2016, daniel wirtz
3
- * compiled thu, 21 may 2026 18:52:08 utc
2
+ * protobuf.js v8.4.2 (c) 2016, daniel wirtz
3
+ * compiled fri, 22 may 2026 02:44:15 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -2455,7 +2455,7 @@ Namespace.arrayToJSON = arrayToJSON;
2455
2455
  Namespace.isReservedId = function isReservedId(reserved, id) {
2456
2456
  if (reserved)
2457
2457
  for (var i = 0; i < reserved.length; ++i)
2458
- if (typeof reserved[i] !== "string" && reserved[i][0] <= id && reserved[i][1] > id)
2458
+ if (typeof reserved[i] !== "string" && reserved[i][0] <= id && reserved[i][1] >= id)
2459
2459
  return true;
2460
2460
  return false;
2461
2461
  };
@@ -3592,6 +3592,9 @@ var base10Re = /^[1-9][0-9]*$/,
3592
3592
  nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,
3593
3593
  typeRefRe = util.patterns.typeRefRe;
3594
3594
 
3595
+ var maxFieldId = 536870911, // 2^29 - 1
3596
+ maxEnumId = 2147483647; // 2^31 - 1
3597
+
3595
3598
  /**
3596
3599
  * Result object returned from {@link parse}.
3597
3600
  * @interface IParserResult
@@ -3711,7 +3714,7 @@ function parse(source, root, options) {
3711
3714
  }
3712
3715
  }
3713
3716
 
3714
- function readRanges(target, acceptStrings) {
3717
+ function readRanges(target, acceptStrings, max, acceptNegative) {
3715
3718
  var token, start;
3716
3719
  do {
3717
3720
  if (acceptStrings && ((token = peek()) === "\"" || token === "'")) {
@@ -3722,7 +3725,7 @@ function parse(source, root, options) {
3722
3725
  }
3723
3726
  } else {
3724
3727
  try {
3725
- target.push([ start = parseId(next()), skip("to", true) ? parseId(next()) : start ]);
3728
+ target.push([ start = parseId(next(), acceptNegative, max), skip("to", true) ? parseId(next(), acceptNegative, max) : start ]);
3726
3729
  } catch (err) {
3727
3730
  if (acceptStrings && typeRefRe.test(token) && edition >= 2023) {
3728
3731
  target.push(token);
@@ -3781,10 +3784,10 @@ function parse(source, root, options) {
3781
3784
  throw illegal(token, "number", insideTryCatch);
3782
3785
  }
3783
3786
 
3784
- function parseId(token, acceptNegative) {
3787
+ function parseId(token, acceptNegative, max) {
3785
3788
  switch (token) {
3786
3789
  case "max": case "MAX": case "Max":
3787
- return 536870911;
3790
+ return max || maxFieldId;
3788
3791
  case "0":
3789
3792
  return 0;
3790
3793
  }
@@ -4242,7 +4245,7 @@ function parse(source, root, options) {
4242
4245
  break;
4243
4246
 
4244
4247
  case "reserved":
4245
- readRanges(enm.reserved || (enm.reserved = []), true);
4248
+ readRanges(enm.reserved || (enm.reserved = []), true, maxEnumId, true);
4246
4249
  if(enm.reserved === undefined) enm.reserved = [];
4247
4250
  break;
4248
4251
 
@@ -9953,7 +9956,7 @@ Writer.prototype.uint32 = function write_uint32(value) {
9953
9956
  * @returns {Writer} `this`
9954
9957
  */
9955
9958
  Writer.prototype.int32 = function write_int32(value) {
9956
- return value < 0
9959
+ return (value |= 0) < 0
9957
9960
  ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec
9958
9961
  : this.uint32(value);
9959
9962
  };
@@ -9968,16 +9971,18 @@ Writer.prototype.sint32 = function write_sint32(value) {
9968
9971
  };
9969
9972
 
9970
9973
  function writeVarint64(val, buf, pos) {
9971
- while (val.hi) {
9972
- buf[pos++] = val.lo & 127 | 128;
9973
- val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;
9974
- val.hi >>>= 7;
9975
- }
9976
- while (val.lo > 127) {
9977
- buf[pos++] = val.lo & 127 | 128;
9978
- val.lo = val.lo >>> 7;
9979
- }
9980
- buf[pos++] = val.lo;
9974
+ var lo = val.lo,
9975
+ hi = val.hi;
9976
+ while (hi) {
9977
+ buf[pos++] = lo & 127 | 128;
9978
+ lo = (lo >>> 7 | hi << 25) >>> 0;
9979
+ hi >>>= 7;
9980
+ }
9981
+ while (lo > 127) {
9982
+ buf[pos++] = lo & 127 | 128;
9983
+ lo = lo >>> 7;
9984
+ }
9985
+ buf[pos++] = lo;
9981
9986
  }
9982
9987
 
9983
9988
  /**