diff --git a/upb/util/def_to_proto.c b/upb/util/def_to_proto.c index 8513206edf..2067bb5b3a 100644 --- a/upb/util/def_to_proto.c +++ b/upb/util/def_to_proto.c @@ -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; } diff --git a/upb/util/def_to_proto_test.cc b/upb/util/def_to_proto_test.cc index 2b3f5e75f2..1fa88a72ae 100644 --- a/upb/util/def_to_proto_test.cc +++ b/upb/util/def_to_proto_test.cc @@ -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