protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Disable HTML Escaping in jsonpb?

Open briansorahan opened this issue 6 years ago • 4 comments

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.

briansorahan avatar Sep 19 '18 15:09 briansorahan

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.

yinzara avatar Jan 11 '19 18:01 yinzara

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

dsnet avatar Jan 11 '19 22:01 dsnet

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.

dsnet avatar Jan 11 '19 22:01 dsnet

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

antoniomo avatar Jun 01 '20 11:06 antoniomo