gogo / protobuf

[Deprecated] Protocol Buffers for Go with Gadgets
Other
5.65k stars 811 forks source link

Disable HTML Escaping in jsonpb? #484

Open briansorahan opened 5 years ago

briansorahan commented 5 years ago

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.

yinzara commented 5 years ago

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.

dsnet commented 5 years ago

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 commented 5 years ago

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.

antoniomo commented 4 years ago

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