Skip to content

Commit

Permalink
fix: properly parse empty messages in options (protobufjs#1429)
Browse files Browse the repository at this point in the history
* Properly parse empty messages in options

* Add missing semicolon in test
  • Loading branch information
murgatroid99 authored and taylorcode committed Oct 16, 2020
1 parent c76496e commit ffc9400
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/parse.js
Expand Up @@ -555,7 +555,7 @@ function parse(source, root, options) {

function parseOptionValue(parent, name) {
if (skip("{", true)) { // { a: "foo" b { c: "bar" } }
do {
while (!skip("}", true)) {
/* istanbul ignore if */
if (!nameRe.test(token = next()))
throw illegal(token, "name");
Expand All @@ -570,7 +570,7 @@ function parse(source, root, options) {
setOption(parent, name + "." + token, readValue(true));
}
skip(",", true);
} while (!skip("}", true));
}
} else
setOption(parent, name, readValue(true));
// Does not enforce a delimiter to be universal
Expand Down
2 changes: 2 additions & 0 deletions tests/data/uncommon.proto
Expand Up @@ -31,6 +31,8 @@ message Test2 {

map<uint64,Test> longmap = 10;

int32 optionTest = 11 [(my_options) = { a: "foo" b {} }];

/** pre */
oneof kind;
oneof kind2; /// post
Expand Down

0 comments on commit ffc9400

Please sign in to comment.