jhump / protoreflect

Reflection (Rich Descriptors) for Go Protocol Buffers
Apache License 2.0
1.35k stars 172 forks source link

String escaping in protoprint is wrong #579

Closed japersik closed 1 year ago

japersik commented 1 year ago

This case (link)

        case '"':
            b.WriteString("\\")

must be

        case '"':
            b.WriteString("\\\"")

otherwise, options with a string value are printed incorrectly example:

option (._mt_string_option) = "Some \"string value\"";

will be converted to

option (._mt_string_option) = "Some \string value\";

and it is an incorrect protobuf file

jhump commented 1 year ago

Fixed in #580. Thanks for the fix, @japersik!!