-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port fix: Fix JSPB binary utf8 decoding and validate by default (breaking change) #191
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you ammend the commit description to clarify that we will now validate utf8 bytes by default
@@ -354,7 +354,7 @@ describe('binaryDecoderTest', () => { | |||
|
|||
const decoder = jspb.BinaryDecoder.alloc(encoder.end()); | |||
|
|||
expect(decoder.readString(len)).toEqual(long_string); | |||
expect(decoder.readString(len, true)).toEqual(long_string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(decoder.readString(len, true)).toEqual(long_string); | |
expect(decoder.readString(len, /* enforceUtf8= */ true)).toEqual(long_string); |
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. |
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.
Co-authored-by: Luke Sandberg <[email protected]>
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.