Skip to content

Commit 85dbbc3

Browse files
ckennellycopybara-github
authored andcommitted
Remove validate-and-log UTF-8 behavior.
Validating consumes CPU and it is easy to overlook log messages. PiperOrigin-RevId: 791275924
1 parent 9806994 commit 85dbbc3

16 files changed

+159
-452
lines changed

src/google/protobuf/compiler/cpp/helpers.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,20 +1535,6 @@ static void GenerateUtf8CheckCode(io::Printer* p, const FieldDescriptor* field,
15351535
}
15361536
break;
15371537

1538-
case internal::cpp::Utf8CheckMode::kVerify:
1539-
if (for_parse) {
1540-
p->Emit(R"cc(
1541-
$pbi$::WireFormat::$Verify$($params$ $pbi$::WireFormat::PARSE,
1542-
"$pkg.Msg.field$");
1543-
)cc");
1544-
} else {
1545-
p->Emit(R"cc(
1546-
$pbi$::WireFormat::$Verify$($params$ $pbi$::WireFormat::SERIALIZE,
1547-
"$pkg.Msg.field$");
1548-
)cc");
1549-
}
1550-
break;
1551-
15521538
case internal::cpp::Utf8CheckMode::kNone:
15531539
break;
15541540
}

src/google/protobuf/compiler/cpp/parse_function_generator.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ void ParseFunctionGenerator::GenerateTailCallTable(io::Printer* p) {
460460
p->Emit(
461461
{
462462
{"strict", utf8_check == Utf8CheckMode::kStrict},
463-
{"verify", utf8_check == Utf8CheckMode::kVerify},
463+
// TODO: Remove this.
464+
{"verify", false},
464465
{"validate", validated_enum},
465466
{"key_wire", map_key->type()},
466467
{"value_wire", map_value->type()},

src/google/protobuf/compiler/plugin.pb.cc

Lines changed: 18 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/compiler/plugin.pb.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/descriptor.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10701,11 +10701,6 @@ bool HasHasbitWithoutProfile(const FieldDescriptor* field) {
1070110701
return GetFieldHasbitModeWithoutProfile(field) != HasbitMode::kNoHasbit;
1070210702
}
1070310703

10704-
static bool IsVerifyUtf8(const FieldDescriptor* field, bool is_lite) {
10705-
if (is_lite) return false;
10706-
return true;
10707-
}
10708-
1070910704
// Which level of UTF-8 enforcemant is placed on this file.
1071010705
Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field, bool is_lite) {
1071110706
if (field->type() == FieldDescriptor::TYPE_STRING ||
@@ -10715,8 +10710,6 @@ Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field, bool is_lite) {
1071510710
FieldDescriptor::TYPE_STRING))) {
1071610711
if (IsStrictUtf8(field)) {
1071710712
return Utf8CheckMode::kStrict;
10718-
} else if (IsVerifyUtf8(field, is_lite)) {
10719-
return Utf8CheckMode::kVerify;
1072010713
}
1072110714
}
1072210715
return Utf8CheckMode::kNone;

src/google/protobuf/descriptor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3195,7 +3195,6 @@ PROTOBUF_EXPORT bool HasHasbitWithoutProfile(const FieldDescriptor* field);
31953195

31963196
enum class Utf8CheckMode : uint8_t {
31973197
kStrict = 0, // Parsing will fail if non UTF-8 data is in string fields.
3198-
kVerify = 1, // Only log an error but parsing will succeed.
31993198
kNone = 2, // No UTF-8 check.
32003199
};
32013200
PROTOBUF_EXPORT Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field,

0 commit comments

Comments
 (0)