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

prefer_integer: exclude numbers with leading zero and negative zero #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

doiken
Copy link

@doiken doiken commented Dec 22, 2019

Current prefer_integer treats numbers with leading zero and negative zero as integer.
This modifies original data, and unpacked data are not the same as original data any more.

This PR fixes it by excluding them from packing as integer.

# current implementation
[root@a5abd099660f /]# perl -MData::MessagePack -E 'say Data::MessagePack->new->unpack(Data::MessagePack->new->prefer_integer->pack("01"))'
1
[root@a5abd099660f /]# perl -MData::MessagePack -E 'say Data::MessagePack->new->unpack(Data::MessagePack->new->prefer_integer->pack("-0"))'
0

# this pr
[root@0ad4d63ab685 /]# perl -MData::MessagePack -E 'say Data::MessagePack->new->unpack(Data::MessagePack->new->prefer_integer->pack("01"))'
01
[root@0ad4d63ab685 /]# perl -MData::MessagePack -E 'say Data::MessagePack->new->unpack(Data::MessagePack->new->prefer_integer->pack("-0"))'
-0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant