You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
encodeCbor() throws on objects with non-ASCII keys #7255
encodeCbor() under-allocates its buffer when an object key contains multi-byte UTF-8 characters, then throws while writing:
import { encodeCbor } from "@std/cbor";
encodeCbor({ "é☃é☃é☃é☃": 1 });
// RangeError: offset is out of bounds
The cause is in calcEncodingSize(): object keys are sized as y.length bytes (cbor/_common_encode.ts:58), but encodeString() writes UTF-8, which needs up to 3 bytes per UTF-16 code unit. String values already account for this with x.length * 3 on line 34. Keys don't.
The fix looks like a one-liner: size keys the same way the value branch does. Happy to PR it.
Activity