emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] Fix definition of whitespace in JSON


From: Philipp Stephani
Subject: [PATCH] Fix definition of whitespace in JSON
Date: Sat, 20 May 2017 17:51:08 +0200

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




reply via email to

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