protobuf-javascript icon indicating copy to clipboard operation
protobuf-javascript copied to clipboard

Port fix: Fix JSPB binary utf8 decoding to be spec compliant.

Open dibenede opened this issue 1 year ago • 0 comments

Our prior behavior was extremely undefined when confronted with errors, it would read out of bounds, accept overlong encodings, skip over out of range bytes, compose out of range codepoints. The new implementation always detects and handles errors consistently by either throwing or using replacement characters (� aka \uFFFD)

This also adds support for aligning with the proto3 spec to the code generator which requires that parsing fail for proto3 messages with invalid utf8 payloads for string fields. For now, actual failing is disabled via the goog.define jspb.binary.ENFORCE_UTF8 which is set to NEVER. A future change will flip this to DEFAULT.

dibenede avatar Feb 15 '24 17:02 dibenede