@ -411,10 +411,6 @@ bool WireFormat::ParseAndMergeMessageSetField(uint32_t field_number,
}
}
static bool StrictUtf8Check ( const FieldDescriptor * field ) {
return field - > file ( ) - > syntax ( ) = = FileDescriptor : : SYNTAX_PROTO3 ;
}
bool WireFormat : : ParseAndMergeField (
uint32_t tag ,
const FieldDescriptor * field , // May be nullptr for unknown
@ -484,8 +480,7 @@ bool WireFormat::ParseAndMergeField(
if ( ! WireFormatLite : : ReadPrimitive < int , WireFormatLite : : TYPE_ENUM > (
input , & value ) )
return false ;
if ( message - > GetDescriptor ( ) - > file ( ) - > syntax ( ) = =
FileDescriptor : : SYNTAX_PROTO3 ) {
if ( ! field - > legacy_enum_field_treated_as_closed ( ) ) {
message_reflection - > AddEnumValue ( message , field , value ) ;
} else {
const EnumValueDescriptor * enum_value =
@ -566,7 +561,7 @@ bool WireFormat::ParseAndMergeField(
// Handle strings separately so that we can optimize the ctype=CORD case.
case FieldDescriptor : : TYPE_STRING : {
bool strict_utf8_check = StrictUtf8Check ( field ) ;
bool strict_utf8_check = field - > requires_utf8_validation ( ) ;
std : : string value ;
if ( ! WireFormatLite : : ReadString ( input , & value ) ) return false ;
if ( strict_utf8_check ) {
@ -868,9 +863,7 @@ const char* WireFormat::_InternalParseAndMergeField(
case FieldDescriptor : : TYPE_ENUM : {
auto rep_enum =
reflection - > MutableRepeatedFieldInternal < int > ( msg , field ) ;
bool open_enum = false ;
if ( field - > file ( ) - > syntax ( ) = = FileDescriptor : : SYNTAX_PROTO3 | |
open_enum ) {
if ( ! field - > legacy_enum_field_treated_as_closed ( ) ) {
ptr = internal : : PackedEnumParser ( rep_enum , ptr , ctx ) ;
} else {
return ctx - > ReadPackedVarint (
@ -982,7 +975,7 @@ const char* WireFormat::_InternalParseAndMergeField(
// Handle strings separately so that we can optimize the ctype=CORD case.
case FieldDescriptor : : TYPE_STRING :
utf8_check = true ;
strict_utf8_check = StrictUtf8Check ( field ) ;
strict_utf8_check = field - > requires_utf8_validation ( ) ;
PROTOBUF_FALLTHROUGH_INTENDED ;
case FieldDescriptor : : TYPE_BYTES : {
int size = ReadSize ( & ptr ) ;
@ -1418,7 +1411,7 @@ uint8_t* WireFormat::InternalSerializeField(const FieldDescriptor* field,
// Handle strings separately so that we can get string references
// instead of copying.
case FieldDescriptor : : TYPE_STRING : {
bool strict_utf8_check = StrictUtf8Check ( field ) ;
bool strict_utf8_check = field - > requires_utf8_validation ( ) ;
std : : string scratch ;
const std : : string & value =
field - > is_repeated ( )