Subject: bug#48274: 27.2; libjanson: \u0000 is not allowed without JSON_ALLOW_NUL

From: Philipp <[email-masked]>
Date: Sat, 8 May 2021 11:24:31 +0200

> Am 07.05.2021 um 09:16 schrieb Peter <[email-masked]>:
> 
> Hello ;)
> 
> It seems that Emacs' `json-parse-buffer' cannot correctly parse strings
> that contain an escaped ascii 0 value.
> 
> To reproduce:
> 
> - Create a new buffer, insert into it:
>  { "foo": "this is a string including a literal \u0000" }
> - Move point to the beginning of the buffer [ M-< ]
> - Execute `json-parse-buffer' [ M-: (json-parse-buffer) ]
> - See the error message.
> 
> According to all other systems I've tried, \u0000 is valid in json
> strings.
> 
> The error message seems to imply that something (probably libjanson?)
> should be compiled with -DJSON_ALLOW_NUL.
> 
> As this seems to be non-conformant behaviour, is there a way to change
> this in the default Emacs build?

We use the default behavior of Jansson here, see the remark about JSON_ALLOW_NUL in https://jansson.readthedocs.io/en/2.13/apiref.html#decoding.
I wouldn't mind allowing escaped NUL characters though; Emacs should be able to handle them just fine.
Also see the FIXME in the unit test `json-parse-string/null' in tests/src/json-tests.el.