diff options
| author | Philipp Stephani | 2017-12-18 23:58:48 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2017-12-19 00:15:01 +0100 |
| commit | 91031a2cfd6b6a3b17c0f8724fd5cccf7c32ed5b (patch) | |
| tree | 7b464e2d4d856f64df4292dc25a7c586cefee617 /src/json.c | |
| parent | 205d02c1b54fa8e18f610cd5deb61a1a3b9bbc01 (diff) | |
| download | emacs-91031a2cfd6b6a3b17c0f8724fd5cccf7c32ed5b.tar.gz emacs-91031a2cfd6b6a3b17c0f8724fd5cccf7c32ed5b.zip | |
; Add a couple of encoding-related FIXMEs to json.c
* src/json.c (json_make_string, json_build_string, json_encode)
(lisp_to_json_toplevel_1, lisp_to_json): Add FIXMEs for problematic
string error reporting.
Diffstat (limited to 'src/json.c')
| -rw-r--r-- | src/json.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/json.c b/src/json.c index 82f670a163e..29e4400fc91 100644 --- a/src/json.c +++ b/src/json.c | |||
| @@ -208,6 +208,7 @@ json_has_suffix (const char *string, const char *suffix) | |||
| 208 | static Lisp_Object | 208 | static Lisp_Object |
| 209 | json_make_string (const char *data, ptrdiff_t size) | 209 | json_make_string (const char *data, ptrdiff_t size) |
| 210 | { | 210 | { |
| 211 | /* FIXME: Raise an error if DATA is not a UTF-8 string. */ | ||
| 211 | return code_convert_string (make_specified_string (data, -1, size, false), | 212 | return code_convert_string (make_specified_string (data, -1, size, false), |
| 212 | Qutf_8_unix, Qt, false, true, true); | 213 | Qutf_8_unix, Qt, false, true, true); |
| 213 | } | 214 | } |
| @@ -219,6 +220,7 @@ json_make_string (const char *data, ptrdiff_t size) | |||
| 219 | static Lisp_Object | 220 | static Lisp_Object |
| 220 | json_build_string (const char *data) | 221 | json_build_string (const char *data) |
| 221 | { | 222 | { |
| 223 | /* FIXME: Raise an error if DATA is not a UTF-8 string. */ | ||
| 222 | return json_make_string (data, strlen (data)); | 224 | return json_make_string (data, strlen (data)); |
| 223 | } | 225 | } |
| 224 | 226 | ||
| @@ -230,6 +232,8 @@ json_build_string (const char *data) | |||
| 230 | static Lisp_Object | 232 | static Lisp_Object |
| 231 | json_encode (Lisp_Object string) | 233 | json_encode (Lisp_Object string) |
| 232 | { | 234 | { |
| 235 | /* FIXME: Raise an error if STRING is not a scalar value | ||
| 236 | sequence. */ | ||
| 233 | return code_convert_string (string, Qutf_8_unix, Qt, true, true, true); | 237 | return code_convert_string (string, Qutf_8_unix, Qt, true, true, true); |
| 234 | } | 238 | } |
| 235 | 239 | ||
| @@ -330,6 +334,8 @@ lisp_to_json_toplevel_1 (Lisp_Object lisp, json_t **json) | |||
| 330 | int status = json_object_set_new (*json, SSDATA (key), | 334 | int status = json_object_set_new (*json, SSDATA (key), |
| 331 | lisp_to_json (HASH_VALUE (h, i))); | 335 | lisp_to_json (HASH_VALUE (h, i))); |
| 332 | if (status == -1) | 336 | if (status == -1) |
| 337 | /* FIXME: A failure here might also indicate that the | ||
| 338 | key is not a valid Unicode string. */ | ||
| 333 | json_out_of_memory (); | 339 | json_out_of_memory (); |
| 334 | } | 340 | } |
| 335 | clear_unwind_protect (count); | 341 | clear_unwind_protect (count); |
| @@ -376,6 +382,8 @@ lisp_to_json (Lisp_Object lisp) | |||
| 376 | else if (STRINGP (lisp)) | 382 | else if (STRINGP (lisp)) |
| 377 | { | 383 | { |
| 378 | Lisp_Object encoded = json_encode (lisp); | 384 | Lisp_Object encoded = json_encode (lisp); |
| 385 | /* FIXME: We might throw an out-of-memory error here if the | ||
| 386 | string is not valid Unicode. */ | ||
| 379 | return json_check (json_stringn (SSDATA (encoded), SBYTES (encoded))); | 387 | return json_check (json_stringn (SSDATA (encoded), SBYTES (encoded))); |
| 380 | } | 388 | } |
| 381 | 389 | ||