-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proto: revert UTF-8 validation for proto2 (#628)
The proto specification officially says that proto2 and proto3 strings should be validated, but pragmatically, compliance with the spec has been poor. For example, the Go implementation did not validate either and added strict validation recently to be compliant. However, this caused signficant breakage. Cases of breakage should change the proto field type from string to the bytes type. However, this is not always possible, when the field is part of the exposed API. This tends to be the case for proto2, where some other notable language implementations (like C++) do not validate proto2 for valid UTF-8. However, since most language implementations do validate for UTF-8 in proto3, we keep that behavior. Making this change for Go is a little tricky since each field does not necessarily know whether it is operating under the proto2 or proto3 syntax. Thus, we modify the generator to emit a "proto3" struct field tag for all fields in proto3. The implications of this change is that people will need to regenerate their proto files to have UTF-8 validation. We expand UTF-8 validation tests to ensure this works for the cross-product of (proto2, proto3) and (scalar, vector, oneof, and maps) fields with strings. Fixes #622
- Loading branch information
Showing
25 changed files
with
1,088 additions
and
620 deletions.
There are no files selected for viewing
230 changes: 115 additions & 115 deletions
230
conformance/internal/conformance_proto/conformance.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.