Commit f677d78
committed
fix(canonical): ensure_ascii=False in legacy canonicalize for cross-lang parity
The legacy canonicalize() serialized string values and object keys with
json.dumps default ensure_ascii=True, which escapes non-ASCII as \uXXXX.
The TypeScript SDK's canonicalize() uses JSON.stringify, which emits raw
UTF-8. Any payload with a non-ASCII character therefore canonicalized
differently in Python than in TypeScript, breaking cross-language
signatures and content hashes for those payloads. Add ensure_ascii=False
to the string-value, object-key, and fallback json.dumps calls. The
strict canonicalize_jcs already did this, so it is unchanged.
ASCII payloads are byte-identical before and after, so existing signatures
and vectors are unaffected; only non-ASCII output changes, to the correct
TypeScript-matching form. Cross-impl raw-UTF-8 test added. Suite 568 passed.1 parent d8c3de1 commit f677d78
2 files changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | | - | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | | - | |
| 55 | + | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
0 commit comments