Skip to content

Commit

Permalink
Add utf8_validation feature back to the global feature set.
Browse files Browse the repository at this point in the history
This will replace the language-specific features, with only java requiring a language-level override.

PiperOrigin-RevId: 568621264
  • Loading branch information
mkruskal-google authored and copybara-github committed Sep 26, 2023
1 parent 7a2c6b5 commit 153028d
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 88 deletions.
1 change: 1 addition & 0 deletions src/google/protobuf/compiler/code_generator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ TEST_F(CodeGeneratorTest, BuildFeatureSetDefaults) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,7 @@ TEST_F(CommandLineInterfaceTest, EditionDefaults) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
}
Expand All @@ -1779,6 +1780,7 @@ TEST_F(CommandLineInterfaceTest, EditionDefaultsWithMaximum) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
}
Expand Down Expand Up @@ -1806,6 +1808,7 @@ TEST_F(CommandLineInterfaceTest, EditionDefaultsWithMinimum) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
}
Expand Down
211 changes: 132 additions & 79 deletions src/google/protobuf/descriptor.pb.cc

Large diffs are not rendered by default.

113 changes: 106 additions & 7 deletions src/google/protobuf/descriptor.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion src/google/protobuf/descriptor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,18 @@ message FeatureSet {
edition_defaults = { edition: EDITION_2023, value: "PACKED" }
];

enum Utf8Validation {
UTF8_VALIDATION_UNKNOWN = 0;
NONE = 1;
VERIFY = 2;
}
optional Utf8Validation utf8_validation = 4 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition: EDITION_2023, value: "VERIFY" }
];

enum MessageEncoding {
MESSAGE_ENCODING_UNKNOWN = 0;
LENGTH_PREFIXED = 1;
Expand All @@ -980,7 +992,7 @@ message FeatureSet {
edition_defaults = { edition: EDITION_2023, value: "ALLOW" }
];

reserved 4, 999;
reserved 999;

extensions 1000; // for Protobuf C++
extensions 1001; // for Protobuf Java
Expand Down
14 changes: 14 additions & 0 deletions src/google/protobuf/descriptor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7544,6 +7544,7 @@ TEST_F(FeaturesTest, Edition2023Defaults) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false utf8_validation: VERIFY_PARSE }
Expand Down Expand Up @@ -7572,6 +7573,7 @@ TEST_F(FeaturesBaseTest, DefaultEdition2023Defaults) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false utf8_validation: VERIFY_PARSE }
Expand All @@ -7595,6 +7597,7 @@ TEST_F(FeaturesTest, ClearsOptions) {
field_presence: IMPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -7857,6 +7860,7 @@ TEST_F(FeaturesTest, NoOptions) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -7888,6 +7892,7 @@ TEST_F(FeaturesTest, FileFeatures) {
field_presence: IMPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -7965,6 +7970,7 @@ TEST_F(FeaturesTest, MessageFeaturesDefault) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -8072,6 +8078,7 @@ TEST_F(FeaturesTest, FieldFeaturesDefault) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -8416,6 +8423,7 @@ TEST_F(FeaturesTest, EnumFeaturesDefault) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -8525,6 +8533,7 @@ TEST_F(FeaturesTest, EnumValueFeaturesDefault) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -8619,6 +8628,7 @@ TEST_F(FeaturesTest, OneofFeaturesDefault) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -8720,6 +8730,7 @@ TEST_F(FeaturesTest, ExtensionRangeFeaturesDefault) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -8806,6 +8817,7 @@ TEST_F(FeaturesTest, ServiceFeaturesDefault) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -8874,6 +8886,7 @@ TEST_F(FeaturesTest, MethodFeaturesDefault) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down Expand Up @@ -9609,6 +9622,7 @@ TEST_F(FeaturesTest, UninterpretedOptions) {
field_presence: IMPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] {
Expand Down
1 change: 1 addition & 0 deletions src/google/protobuf/editions/generated_files_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ TEST(Generated, EditionDefaults2023InternalFeatures) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false utf8_validation: VERIFY_PARSE }
Expand Down
2 changes: 2 additions & 0 deletions src/google/protobuf/feature_resolver_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,7 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsMinimumCovered) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.test] { int_file_feature: 1 }
Expand All @@ -1008,6 +1009,7 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsMinimumCovered) {
field_presence: EXPLICIT
enum_type: OPEN
repeated_field_encoding: PACKED
utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.test] { int_file_feature: 2 }
Expand Down
Loading

0 comments on commit 153028d

Please sign in to comment.