Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: possible infinite loop when parsing option #1923

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bench/prof.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ function setupBrowser() {
switch (process.argv[2]) {
case "encode-browser":
setupBrowser();
// eslint-disable-line no-fallthrough
// eslint-disable-next-line no-fallthrough
case "encode":
for (var i = 0; i < count; ++i)
Test.encode(data).finish();
break;
case "decode-browser":
setupBrowser();
// eslint-disable-line no-fallthrough
// eslint-disable-next-line no-fallthrough
case "decode":
var buf = Test.encode(data).finish();
for (var j = 0; j < count; ++j)
Expand Down
2 changes: 1 addition & 1 deletion cli/lib/tsd-jsdoc/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ function handleElement(element, parent) {
handleEnum(element, parent);
break;
}
// eslint-disable-line no-fallthrough
// eslint-disable-next-line no-fallthrough
case "namespace":
handleNamespace(element, parent);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
break;
case "uint64":
isUnsigned = true;
// eslint-disable-line no-fallthrough
// eslint-disable-next-line no-fallthrough
case "int64":
case "sint64":
case "fixed64":
Expand Down Expand Up @@ -176,7 +176,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
break;
case "uint64":
isUnsigned = true;
// eslint-disable-line no-fallthrough
// eslint-disable-next-line no-fallthrough
case "int64":
case "sint64":
case "fixed64":
Expand Down
5 changes: 4 additions & 1 deletion src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function parse(source, root, options) {
break;
case "public":
next();
// eslint-disable-line no-fallthrough
// eslint-disable-next-line no-fallthrough
default:
whichImports = imports || (imports = []);
break;
Expand Down Expand Up @@ -621,6 +621,9 @@ function parse(source, root, options) {
if (!nameRe.test(token = next())) {
throw illegal(token, "name");
}
if (token === null) {
throw illegal(token, "end of input");
}

var value;
var propName = token;
Expand Down
4 changes: 1 addition & 3 deletions tests/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,14 @@ tape.test("pbjs generates static code with message filter", function (test) {
var $protobuf = protobuf;
eval(jsCode);

console.log(protobuf.roots);

var NeedMessage1 = protobuf.roots.default.filtertest.NeedMessage1;
var NeedMessage2 = protobuf.roots.default.filtertest.NeedMessage2;
var DependentMessage1 = protobuf.roots.default.filtertest.DependentMessage1;
var DependentMessageFromImport = protobuf.roots.default.DependentMessageFromImport;

var NotNeedMessageInRootFile = protobuf.roots.default.filtertest.NotNeedMessageInRootFile;
var NotNeedMessageInImportFile = protobuf.roots.default.NotNeedMessageInImportFile;

test.ok(NeedMessage1, "NeedMessage1 is loaded");
test.ok(NeedMessage2, "NeedMessage2 is loaded");
test.ok(DependentMessage1, "DependentMessage1 is loaded");
Expand Down
5 changes: 5 additions & 0 deletions tests/comp_options-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,10 @@ tape.test("Options", function (test) {
test.end();
});

test.test(test.name + " - invalid option", function (test) {
test.throws(() => { protobuf.parse("option (foo).whatever = {")});
test.end();
});

test.end();
});