gslone
gslone8mo ago

Null bytes in JSON

Hey, I want to pass a JSON object into a script that must contain null-bytes in strings. Like so:
{
"unicodePwd": "a\u0000"
}
{
"unicodePwd": "a\u0000"
}
(background: the LDAP password attribute must be passed as UTF-16) I'm getting the error "error returned from database: unsupported Unicode escape sequence". It should be valid JSON though, and other JSON parsers seem to accept this. Is there anything that I can do here?
2 Replies
rubenf
rubenf8mo ago
yes it's a limitation of postgresql, it doesn't like null bytes at all do you absolutely need that null byte ?
gslone
gsloneOP8mo ago
Ah. That's unfortunate. I will work around it, but it will be a bit nasty - I have to catch the case where a user wants to modify the unicodePwd attribute and create a bespoke code path for it. not the end of the world!