protocolbuffers / protobuf-javascript

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

Port fix: Fix JSPB binary utf8 decoding and validate by default (breaking change) #191

Closed dibenede closed 2 months ago

dibenede commented 7 months ago

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.

ribrdb commented 2 months ago

What's the status of this? Is there a reason it hasn't been merged?

dibenede commented 2 months ago

What's the status of this? Is there a reason it hasn't been merged?

This will be going in shortly. I wanted to cut a release beforehand, which is now done. However, that was slow to get out the door due to release infrastructure issues.