From: Philipp Stephani <p.stephani2@gmail.com>
To: emacs-devel@gnu.org
Cc: Philipp Stephani <phst@google.com>
Subject: [PATCH] Fix definition of whitespace in JSON
Date: Sat, 20 May 2017 17:51:08 +0200 [thread overview]
Message-ID: <20170520155108.7692-1-phst@google.com> (raw)
In-Reply-To: <CAP_d_8WA2JCf6ZWNdiyuuoVo9hBHziuF=ALCT+jpuuOyiafUwQ@mail.gmail.com>
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 "))
\f
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
next prev parent reply other threads:[~2017-05-20 15:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-05 17:51 two json.el bugs Theresa O'Connor
2017-05-05 18:44 ` Yuri Khan
2017-05-05 19:25 ` Drew Adams
2017-05-20 15:51 ` Philipp Stephani [this message]
2017-05-20 17:28 ` [PATCH] Fix definition of whitespace in JSON Dmitry Gutov
2017-05-21 21:03 ` Philipp Stephani
2017-05-27 13:32 ` two json.el bugs Philipp Stephani
2017-05-27 13:48 ` Philipp Stephani
2017-05-28 1:30 ` Drew Adams
2017-05-28 18:47 ` Philipp Stephani
2017-05-28 22:12 ` Drew Adams
2017-05-28 22:44 ` Bruce V Chiarelli
2017-05-29 0:42 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170520155108.7692-1-phst@google.com \
--to=p.stephani2@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=phst@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.