protocolbuffers / protobuf-javascript

BSD 3-Clause "New" or "Revised" License
375 stars 67 forks source link

Catch non-strings in BinaryEncoder.writeString #108

Closed dweitzman closed 2 years ago

dweitzman commented 2 years ago

The javascript serializeBinary() function silently tosses away any non-string placed into what should be a string field, writing the equivalent of an empty string instead

Not sure if or why anyone would be relying on that existing arbitrary behavior today, but silent data loss seems very undesirable and worth defending against

This PR was previously sent at https://github.com/protocolbuffers/protobuf/pull/9584 in the older repo