emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Improve error reporting when serializing non-Unicode strings


From: Philipp Stephani
Subject: Re: [PATCH] Improve error reporting when serializing non-Unicode strings to JSON
Date: Sat, 23 Dec 2017 12:33:46 +0000



Eli Zaretskii <address@hidden> schrieb am Sa., 23. Dez. 2017 um 09:28 Uhr:
> From: Philipp Stephani <address@hidden>
> Date: Fri, 22 Dec 2017 22:00:31 +0100
> Cc: Philipp Stephani <address@hidden>
>
> * admin/merge-gnulib (GNULIB_MODULES): Add unistr modules.
>
> * lib/Makefile.in (.c.o): Fix output file for files in subdirectories.
> (${DEPDIR}/unistr, unistr/u8-check.o): Create missing deps directory.
>
> * src/json.c (json_check_utf8): New helper function.
> (lisp_to_json_toplevel_1, lisp_to_json): Use it.  To save a bit of
> time, check for invalid UTF-8 strings only after encountering an
> error, since Jansson already rejects them.
>
> * test/src/json-tests.el (json-serialize/invalid-unicode): Adapt
> expected error symbol.

I'm not sure I understand the need for this.  Emacs never does that
anywhere else, it just converts the invalid bytes to a special
character set.  An application that cares could then test for presence
of those bytes to see if anything like that happened.  What am I
missing?

This patch only improves the error symbol when trying to serialize a non-Unicode string to JSON. Right now this raises "out of memory", which is somewhat confusing. This patch improves this to raise "wrong-type-argument".

reply via email to

[Prev in Thread] Current Thread [Next in Thread]