protobufjs 7.2.1 → 7.2.3

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.1",
3
+ "version": "7.2.3",
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
@@ -274,6 +274,10 @@ function tryHandleExtension(root, field) {
274
274
  var extendedType = field.parent.lookup(field.extend);
275
275
  if (extendedType) {
276
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
+ }
277
281
  sisterField.declaringField = field;
278
282
  field.extensionField = sisterField;
279
283
  extendedType.add(sisterField);