Kinto / kinto-signer

Digital signatures to guarantee integrity and authenticity of collections of records.
12 stars 7 forks source link

Fix canonical JSON corner cases #65

Closed leplatrem closed 3 years ago

leplatrem commented 8 years ago
#
# Failing tests
#
# XXX: those will probably require to rewrite the whole suite of tests.
#
# def test_serializes_nan_to_null():
#     records = [{'id': '4', 'a': float('nan')}]
#     assert canonical_json(records) == '[{"a":null,"id":4}]'
#
#
# def test_serializes_numbers_as_is():
#     records = [{'id': '4', 'a': -0, 'b': 3.50}]
#     assert canonical_json(records) == '[{"a":-0,"b":3.50,"id":"4"}]'
#
#
# def test_serializes_infinity_to_null():
#     records = [{'id': '4', 'a': float("inf")}]
#     assert canonical_json(records) == '[{"a":null,"id":"4"}]'

The idea to serialize -0 and +0 differently came form the IETF draft from rundgren.

Given the fact that it's not easy to do with Python (and not reliable across languages), we might want to drop support for such corner case?

I don't think Python got a concept of "not a number / nan" so we probably should just throw this test.

In python, some pointers: http://stackoverflow.com/a/7781273

leplatrem commented 3 years ago

Now using canonicaljson Rust implementation #1260