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: [PATCH] Fix definition of whitespace in JSON Date: Sat, 20 May 2017 17:51:08 +0200 Message-ID: <20170520155108.7692-1-phst@google.com> References: NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1495295520 30822 195.159.176.226 (20 May 2017 15:52:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 20 May 2017 15:52:00 +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 May 20 17:51:55 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 1dC6fb-0007rF-46 for ged-emacs-devel@m.gmane.org; Sat, 20 May 2017 17:51:55 +0200 Original-Received: from localhost ([::1]:34633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dC6fe-00031w-TW for ged-emacs-devel@m.gmane.org; Sat, 20 May 2017 11:51:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dC6f1-00031f-Gv for emacs-devel@gnu.org; Sat, 20 May 2017 11:51:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dC6ey-0006rV-EB for emacs-devel@gnu.org; Sat, 20 May 2017 11:51:19 -0400 Original-Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:32907) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dC6ey-0006r1-6h for emacs-devel@gnu.org; Sat, 20 May 2017 11:51:16 -0400 Original-Received: by mail-wm0-x241.google.com with SMTP id b84so7617427wmh.0 for ; Sat, 20 May 2017 08:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XmM+TlRa8iKfMEqsDvHdIooFXrEoj32wE4rrF3BAgIc=; b=qqqPvsWfQIky35siA5vl5Ob/xdJPDLADMLDHSKeL9in+WBSKUvjB74dLwOLYIIx/vq tLt3qfo9sk52tWhIcAZYtqIVc7SfuhbzbHe2TOu8VNjppbC48F6F+usyOnAb1/eIYKgU HdRFtpwhEgzRhk8dg9GPsSo2b6N6fL9ipRDFyVM34qElDw0tq4phvUCznD1iJdzA/P87 h3YdbBL+ZvNThr2GgQ2Z/kN9BDeiYsrnP8XrUJxG05oVpO+waAwnezBnWdc4pjyfjl4F imP/z5q0z2aj4RnS13hI3cK2jI/6ufFCF36XT0kOF9dkjexkPYCW22rz8AwZgoC81LYx U66w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XmM+TlRa8iKfMEqsDvHdIooFXrEoj32wE4rrF3BAgIc=; b=dyHYn4wX0TrOoixfW+YgSW2gesdthuaecsRCAZ0ScL/BYnvACmGUgASEG0IQSot5aW VxeOdixOGB/DD7bo/zbt2lo+O93RwHlT2FYoN9RmI6OUf2FSQ2cURuEEUN2dXg+lq7Y0 Oip58fy06RlmVwks01tmaTtm9tD7MNA94aKK3CzgaAiyR6QhN0QHpwHQIz88OZx7bolN yByGne6fqjnp95p0SYUzm6WvSo0gV/7ldZnyeC/+/lO+7HKZhyMJGw3fU4FLenhmajyE B17w/dMh0CQ7J6hxPM23KV/f2wlsRyPPPJdeHR+VrOonEkQgWU1WOxToc7lhsZXjltuZ 1aZg== X-Gm-Message-State: AODbwcA7V/ZzAbODbQqMdX4Yxy9cX6Zth/jWg+MS4819ab1Oj49C5vXw hoxyd3hUr7se1w== X-Received: by 10.28.13.1 with SMTP id 1mr10273819wmn.12.1495295474946; Sat, 20 May 2017 08:51:14 -0700 (PDT) Original-Received: from p.cm.cablesurf.de (46.128.198.151.dynamic.cablesurf.de. [46.128.198.151]) by smtp.gmail.com with ESMTPSA id k15sm7542300wmg.10.2017.05.20.08.51.13 (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 20 May 2017 08:51:13 -0700 (PDT) X-Google-Original-From: Philipp Stephani X-Mailer: git-send-email 2.13.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 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:215028 Archived-At: See https://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00115.html. * lisp/json.el (json-skip-whitespace): Fix definition. * test/lisp/json-tests.el (test-json-skip-whitespace): Adapt unit test. --- lisp/json.el | 6 +++++- test/lisp/json-tests.el | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/json.el b/lisp/json.el index 5f403a411b..3def94ce04 100644 --- a/lisp/json.el +++ b/lisp/json.el @@ -206,7 +206,11 @@ json-pop (defun json-skip-whitespace () "Skip past the whitespace at point." - (skip-chars-forward "\t\r\n\f\b ")) + ;; See + ;; https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf + ;; or https://tools.ietf.org/html/rfc7159#section-2 for the + ;; definition of whitespace in JSON. + (skip-chars-forward "\t\r\n ")) diff --git a/test/lisp/json-tests.el b/test/lisp/json-tests.el index 38672de066..c6bd295d66 100644 --- a/test/lisp/json-tests.el +++ b/test/lisp/json-tests.el @@ -89,7 +89,10 @@ json-tests--with-temp-buffer (ert-deftest test-json-skip-whitespace () (json-tests--with-temp-buffer "\t\r\n\f\b { \"a\": 1 }" (json-skip-whitespace) - (should (equal (char-after (point)) ?{)))) + (should (equal (char-after) ?\f))) + (json-tests--with-temp-buffer "\t\r\n\t { \"a\": 1 }" + (json-skip-whitespace) + (should (equal (char-after) ?{)))) ;;; Paths -- 2.13.0