Commit e6650bf
committed
pgproto3: hex-decode CopyData.Data in UnmarshalJSON
MarshalJSON encodes Data with hex.EncodeToString but UnmarshalJSON did
[]byte(msg.Data), so round-tripping any CopyData with non-text bytes
through JSON would silently corrupt the payload (e.g. [0x01 0x02 0xff]
came back as the literal bytes for the string "0102ff"). Now mirrors
the marshal side with hex.DecodeString, with the empty-Data shortcut
preserved so the existing TestJSONUnmarshalCopyData fixture still
unmarshals to []byte{}.
Added a round-trip test.
Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>1 parent 5e5c1a2 commit e6650bf
2 files changed
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
58 | 66 | | |
59 | 67 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
175 | 194 | | |
176 | 195 | | |
177 | 196 | | |
| |||
0 commit comments