From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Improve error reporting when serializing non-Unicode strings to JSON Date: Sat, 30 Dec 2017 22:20:26 +0000 Message-ID: References: <20171223165857.25743-1-phst@google.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c122b70950c21056196286e" X-Trace: blaine.gmane.org 1514672368 11031 195.159.176.226 (30 Dec 2017 22:19:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 30 Dec 2017 22:19:28 +0000 (UTC) Cc: Philipp Stephani To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 30 23:19:23 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eVPTK-0002Gz-Ls for ged-emacs-devel@m.gmane.org; Sat, 30 Dec 2017 23:19:18 +0100 Original-Received: from localhost ([::1]:42303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eVPVJ-0006xw-N6 for ged-emacs-devel@m.gmane.org; Sat, 30 Dec 2017 17:21:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eVPUd-0006xD-7P for emacs-devel@gnu.org; Sat, 30 Dec 2017 17:20:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eVPUc-0007hW-Aa for emacs-devel@gnu.org; Sat, 30 Dec 2017 17:20:39 -0500 Original-Received: from mail-qt0-x229.google.com ([2607:f8b0:400d:c0d::229]:33823) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eVPUc-0007hE-5Q for emacs-devel@gnu.org; Sat, 30 Dec 2017 17:20:38 -0500 Original-Received: by mail-qt0-x229.google.com with SMTP id 33so57593272qtv.1 for ; Sat, 30 Dec 2017 14:20:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+E2xR+SN5UmRowL/DZ1yY9+5+FyXBgKWMaDZ8tGlQr0=; b=FOqRfrBi0cr4cf5Ku3dxx4+7ng308SH4CHnbaPdHcOMM98eF3K0cYCpuLNuG6MwF/f k3Y4tO2XgTyNHkWZg1VPdqqzQjJhPv+eP/GyV2CRh+jK2BFspn6XrGETbf6P4kuz3XBw DVieUeZLVX+REPzRcAqHsjQGkC3coJrwKOK6TZVRGcZDfZAqEmsrc+9LOGZCa6Yx8ebF 6bq51rjoIrO1di3aLTsMAgzlYHhz0SnjpFeiz+IiiUVPJrd6lAcxh/ag2j5uX4U+S7DU Be5p9NfkqV/hUFkbR/+P7ViqbvsoRc3gIzyet+EW4CYSboqBpCD37LdfiZV8jzlm8fpv 25OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+E2xR+SN5UmRowL/DZ1yY9+5+FyXBgKWMaDZ8tGlQr0=; b=lRj+z74Ze0Vs2+L769k8KG24pAXPteQV0L1ZrYIHSLKX2kp2/n9nBgdK5tajZZ3GmS SwpUAht9OjH20Su4MltorwunQnRgLfoJDXm7yiqAZ7j3WBR3X3NlVYUgzIWi/l1OkW+J VSM+TJdoNLnN1gG/7rVRKJlGuNxn7SQgBOueyNsrQqUUqyFiE/vgDBWp62/3LUJXjf90 ta54NWP0PCLLHmz/fmZgCSUHRfmvip2aSl1obbCUBLmOKV2WsRUIghm7jDs1AjXx5ixk RRgv6/lDtwiNMZgmD2BcE3PqEEAdOewQCuaaxnUMz4NP0Rk0QumOodD1GluOnadPBqgj Ni6Q== X-Gm-Message-State: AKGB3mK2BqdM1svBMJyqhDqB89b/EjtYZ5YupXdkqdXHbwotQg9YLyrg EWthwxA6oApTr+QTf9A+ZduETKX3YZEwXMWs/GZ0CA== X-Google-Smtp-Source: ACJfBos2WsuY+NpWS7jcw0oBcQxqquV7VjmJ/W6M8ZzOhNfUo3LMAqm5cR4YUY+NE8r7JFB5foJBd8OHtAJrEG9D+P0= X-Received: by 10.200.27.76 with SMTP id p12mr54532277qtk.310.1514672437397; Sat, 30 Dec 2017 14:20:37 -0800 (PST) In-Reply-To: <20171223165857.25743-1-phst@google.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221477 Archived-At: --94eb2c122b70950c21056196286e Content-Type: text/plain; charset="UTF-8" Philipp Stephani schrieb am Sa., 23. Dez. 2017 um 17:59 Uhr: > * src/coding.h (EOL_SEEN_NONE, EOL_SEEN_LF, EOL_SEEN_CR) > (EOL_SEEN_CRLF): Move from coding.c. > > * src/coding.c (check_utf_8): Make extern. > > * 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've pushed a slight variant of this patch to master as a5835dfee1. The only difference is that the UTF-8 check is factored out into a helper function in coding.c. --94eb2c122b70950c21056196286e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Philip= p Stephani <p.stephani2@gmail.c= om> schrieb am Sa., 23. Dez. 2017 um 17:59=C2=A0Uhr:
* src/coding.h (EOL_SEEN_NONE, EOL_SEEN_LF, EOL_SE= EN_CR)
(EOL_SEEN_CRLF): Move from coding.c.

* src/coding.c (check_utf_8): Make extern.

* src/json.c (json_check_utf8): New helper function.
(lisp_to_json_toplevel_1, lisp_to_json): Use it.=C2=A0 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've pushed a slight variant of this p= atch to master as a5835dfee1. The only difference is that the UTF-8 check i= s factored out into a helper function in coding.c.=C2=A0
--94eb2c122b70950c21056196286e--