Skip to content
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

fix!: encoding of empty Buffers #1514

Merged
merged 2 commits into from Dec 7, 2020
Merged

fix!: encoding of empty Buffers #1514

merged 2 commits into from Dec 7, 2020

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Dec 2, 2020

closes #1500
fixes #885

The fix is from @jawid-h in #1500. Thanks to him.
I added tests.

Note the change in behavior:

-                test.same(obj.bytesVal, [], "should set bytesVal");
+                test.same(obj.bytesVal, protobuf.util.newBuffer(0), "should set bytesVal");

The default value for an empty Buffer is now a Buffer of length 0 vs an empty array before.

I have not included the generated files in this CL (dist/* and index.d.ts).
Please let me know if they should be there and I'll add them.

@alexander-fenster alexander-fenster changed the title fix encoding of empty Buffers fix!: encoding of empty Buffers Dec 4, 2020
Copy link
Contributor

@alexander-fenster alexander-fenster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked a little bit and decided it's a breaking change and should go to v7.0 which hopefully will be released soon enough.

@vicb
Copy link
Contributor Author

vicb commented Dec 5, 2020

Thanks for the update @alexander-fenster.

I think it's definitely safer to release this in a major version as there might be users relying on the current behavior.

@bcoe bcoe merged commit b4cae07 into protobufjs:master Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty buffer with "repeated byte" lead to exception
3 participants