mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
The CBOR encoder walked string-keyed tables with lua_next (pairs() order), which Lua does not guarantee to be stable. The pfUI export path rebuilds its config tables on every press, so each rebuild re-hashed the same keys into a different internal layout and the map serialized its key/value pairs in a different byte order -> different compressed bytes -> different Base64. Harmless (every variant decodes to the same config) but no stable fingerprint. EncodeTable's map branch now stashes each key, records its encoded bytes, sorts by encoded-key bytes (shorter first, then bytewise per RFC 7049 3.9), then re-fetches key/value in sorted order. Nested maps sort recursively, so the whole byte stream is canonical. Decode is order-agnostic, so the round trip stays lossless. Verified in-game: encode/decode/re-encode of a pfUI profile now produces a byte-identical Base64 string.