One function
dump in trailofbits/rfc8785.py
The author described this change as “rfc8785: raise CanonicalizationError on nonstr keys (#11)”. It counts as a record because the check below fails on the code as it stood at d8b4a6445 and passes on 1796ae7ba, with nothing else changed between the two runs.
Projecttrailofbits/rfc8785.py
Fix saved2024-03-20
Sharing licenceApache-2.0 · LICENSE
Change size+5 −1
What the code was meant to do, written into the code itself as a docstring
Perform JCS serialization of `obj` into `sink`.
The change
| 44 | 44 | # RFC 8785 3.2.3: Objects are sorted by key; keys are ordered | |
| 45 | 45 | # by their UTF-16 encoding. The spec isn't clear about which endianness, | |
| 46 | 46 | # but the examples imply that the big endian encoding is used. | |
| 47 | - | obj_sorted = sorted(obj.items(), key=lambda kv: kv[0].encode("utf-16be")) | |
| 47 | + | try: | |
| 48 | + | obj_sorted = sorted(obj.items(), key=lambda kv: kv[0].encode("utf-16be")) | |
| 49 | + | except AttributeError: | |
| 50 | + | # Failing to call `encode()` indicates that a key isn't a string. | |
| 51 | + | raise CanonicalizationError("object keys must be strings") | |
| 48 | 52 | ||
| 49 | 53 | sink.write(b"{") | |
| 50 | 54 | for idx, (key, value) in enumerate(obj_sorted): |
The check that tells the two apart
fail→pass·test/test_impl.py::test_dumps_nonstring_key
Check file test/test_impl.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itd8b4a6445f38c48b9137a8099706d9b8073146e4
Broken version dated2024-03-19
Modulerfc8785._impl
Units changeddump
Fingerprintd7e1f81f41517880
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.