protobuf
protobuf copied to clipboard
Disable HTML Escaping in jsonpb?
Opening this for discussion. Here is the golang/protobuf issue for the same topic https://github.com/golang/protobuf/issues/407 Should gogo enable this? Would be really nice to have.
I agree. When exposing an external web service, many times you can't make any guarantee about who is consuming the service and their ability to handle unmarshalling data encoded this way.
If gogo/protobuf messages implement the upcoming v2 message interface, the gogo/protobuf project wouldn't have to maintain their own version of jsonpb. In my opinion it is healthier for the Go protobuf ecosystem if the v2 jsonpb
package worked for golang/protobuf
generated messages, gogo/protobuf
generated message, or even dynamic messages, so long as they satisfy the new message interface (which knows how to behaviorally describe itself).
The currently implementation of v2 jsonpb
does not do HTML escaping (but could change). See my comment in: https://go-review.googlesource.com/c/protobuf/+/134495
ability to handle unmarshalling data encoded this way.
I should also note that the escaped HTML characters is still fully compliant with RFC 7159, so this is still indicative of a bug with those clients.
For those looking for a solution, a possible workaround is https://github.com/gogo/protobuf/pull/694. I'll also maintain this fork for use with the grpc-gateway: https://github.com/antoniomo/gateway