Removed some special escapes from def_to_proto.c, to match C++ protos.

This was not a bug -- the previous behavior was correct.  However this
change brings our implementation-specific details in line with C++.

PiperOrigin-RevId: 511273853
pull/13171/head
Joshua Haberman 2 years ago committed by Copybara-Service
parent a7a097d443
commit 2d40e1e2ee
  1. 12
      upb/util/def_to_proto.c
  2. 15
      upb/util/def_to_proto_test.cc

@ -102,28 +102,20 @@ static bool upb_isprint(char ch) { return ch >= 0x20 && ch <= 0x7f; }
static int special_escape(char ch) {
switch (ch) {
case '\a':
return 'a';
case '\b':
return 'b';
case '\f':
return 'f';
// This is the same set of special escapes recognized by
// absl::CEscape().
case '\n':
return 'n';
case '\r':
return 'r';
case '\t':
return 't';
case '\v':
return 'v';
case '\\':
return '\\';
case '\'':
return '\'';
case '"':
return '"';
case '\?':
return '?';
default:
return -1;
}

@ -301,4 +301,19 @@ TEST(FuzzTest, PackageStartsWithNumber) {
ParseTextProtoOrDie(R"pb(file { name: "" package: "0" })pb"));
}
TEST(FuzzTest, RoundTripDescriptorRegression) {
RoundTripDescriptor(ParseTextProtoOrDie(R"pb(file {
name: ""
message_type {
name: "A"
field {
name: "B"
number: 1
type: TYPE_BYTES
default_value: "\007"
}
}
})pb"));
}
} // namespace upb_test

Loading…
Cancel
Save