ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.85k stars 295 forks source link

Correctly handle literal \ufffd chars when encoding JSON #320

Closed cvermilion closed 4 years ago

cvermilion commented 4 years ago

Fixes #313. Fixes #317.

utf8.DecodeRuneInString uses this rune to signal errors, but it can also be present as a literal rune in the string.

Without this fix, encoding a string that contains results in an infinite loop. I wasn't sure where the best place to extend the tests would be; adding a string with this rune in it to the primitives list at the top causes tests involving other encoders to fail.