ubjson / universal-binary-json

Community workspace for the Universal Binary JSON Specification.
115 stars 12 forks source link

Collision between U and i markers #47

Closed kxepal closed 10 years ago

kxepal commented 10 years ago

Found interesting issue. In UBJSON specification there are two integer types with overlapping ranges:

If value is in range of both (say, it's 42), which marker one should have priority to be used? The problem occurs then two different UBJSON libraries are able to produce different data (byte-wise) for the same content. While it still decodes well, this situation creates problems with chechsums and hashes.

Currently, I stay with policy when i is tried to be used before U, but I wonder how others deals with that.

meisme commented 10 years ago

There will be other collisions as well. I do not think you should force implementations to work a spesific way, since the most optimal choices for specific applications will differ. Like JSON the spec doesn't mean for data to be compaired bytewise.

ghost commented 10 years ago

@kxepal it shouldn't matter if you are dealing with supporting platforms, but your order of operations (i then U) is how I intended it.