protobufjs 7.2.0 → 7.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "protobufjs",
3
- "version": "7.2.0",
3
+ "version": "7.2.4",
4
4
  "versionScheme": "~",
5
5
  "description": "Protocol Buffers for JavaScript (& TypeScript).",
6
6
  "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
package/src/parse.js CHANGED
@@ -360,6 +360,16 @@ function parse(source, root, options) {
360
360
  parseGroup(parent, rule);
361
361
  return;
362
362
  }
363
+ // Type names can consume multiple tokens, in multiple variants:
364
+ // package.subpackage field tokens: "package.subpackage" [TYPE NAME ENDS HERE] "field"
365
+ // package . subpackage field tokens: "package" "." "subpackage" [TYPE NAME ENDS HERE] "field"
366
+ // package. subpackage field tokens: "package." "subpackage" [TYPE NAME ENDS HERE] "field"
367
+ // package .subpackage field tokens: "package" ".subpackage" [TYPE NAME ENDS HERE] "field"
368
+ // Keep reading tokens until we get a type name with no period at the end,
369
+ // and the next token does not start with a period.
370
+ while (type.endsWith(".") || peek().startsWith(".")) {
371
+ type += next();
372
+ }
363
373
 
364
374
  /* istanbul ignore if */
365
375
  if (!typeRefRe.test(type))
package/src/root.js CHANGED
@@ -98,10 +98,10 @@ Root.prototype.load = function load(filename, options, callback) {
98
98
  /* istanbul ignore if */
99
99
  if (!callback)
100
100
  return;
101
- if (sync)
102
- throw err;
103
101
  var cb = callback;
104
102
  callback = null;
103
+ if (sync)
104
+ throw err;
105
105
  cb(err, root);
106
106
  }
107
107
 
@@ -145,6 +145,7 @@ Root.prototype.load = function load(filename, options, callback) {
145
145
 
146
146
  // Fetches a single file
147
147
  function fetch(filename, weak) {
148
+ filename = getBundledFileName(filename) || filename;
148
149
 
149
150
  // Skip if already loaded / attempted
150
151
  if (self.files.indexOf(filename) > -1)
@@ -273,6 +274,10 @@ function tryHandleExtension(root, field) {
273
274
  var extendedType = field.parent.lookup(field.extend);
274
275
  if (extendedType) {
275
276
  var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options);
277
+ //do not allow to extend same field twice to prevent the error
278
+ if (extendedType.get(sisterField.name)) {
279
+ return true;
280
+ }
276
281
  sisterField.declaringField = field;
277
282
  field.extensionField = sisterField;
278
283
  extendedType.add(sisterField);
@@ -288,7 +288,7 @@ function newError(name) {
288
288
  configurable: true,
289
289
  },
290
290
  name: {
291
- get() { return name; },
291
+ get: function get() { return name; },
292
292
  set: undefined,
293
293
  enumerable: false,
294
294
  // configurable: false would accurately preserve the behavior of
@@ -298,7 +298,7 @@ function newError(name) {
298
298
  configurable: true,
299
299
  },
300
300
  toString: {
301
- value() { return this.name + ": " + this.message; },
301
+ value: function value() { return this.name + ": " + this.message; },
302
302
  writable: true,
303
303
  enumerable: false,
304
304
  configurable: true,
package/src/util.js CHANGED
@@ -176,7 +176,7 @@ util.decorateEnum = function decorateEnum(object) {
176
176
  util.setProperty = function setProperty(dst, path, value) {
177
177
  function setProp(dst, path, value) {
178
178
  var part = path.shift();
179
- if (part === "__proto__") {
179
+ if (part === "__proto__" || part === "prototype") {
180
180
  return dst;
181
181
  }
182
182
  if (path.length > 0) {