protocolbuffers / protocolbuffers/protobuf
Parser erroneously allows whitespace in package declaration.
Open
@esrauchg is already working on this.
Since May 12, 2026.
bug
c++
documentation
keep open
P3
- Dominant language
- C++
- Stars
- 72k
- Forks
- 16.3k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 140
Description
We had a case where protoc allowed a package declaration that had newlines in it but other tooling based on the spec failed to parse the file. I believe this should have failed to parse inside protoc as well.
Relevant parts of the spec:
package = "package" fullIdent ";"
fullIdent = ident { "." ident }
ident = letter { letter | decimalDigit | "_" }
letter = "A" … "Z" | "a" … "z"
decimalDigit = "0" … "9"
Example showing protoc allowing newlines:
$ echo "package example.
foo
;
message Foo {}" > test.proto
$ protoc --version
libprotoc 3.0.0
$ protoc --java_out=. test.proto
[libprotobuf WARNING google/protobuf/compiler/parser.cc:547] No syntax specified for the proto file: test.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
$ tree
.
├── example
│ └── foo
│ └── Test.java
└── test.proto
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.