aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Stephani2017-05-20 17:49:06 +0200
committerPhilipp Stephani2017-05-21 23:03:01 +0200
commit32f80eb678c4dc6335063cc39975bbce2766829a (patch)
tree2b50a491868c30fa73b1558212f12fd03a3e09ed
parent140aefc341da9cc865971d393071be029ff8b3c5 (diff)
downloademacs-32f80eb678c4dc6335063cc39975bbce2766829a.tar.gz
emacs-32f80eb678c4dc6335063cc39975bbce2766829a.zip
Fix definition of whitespace in JSON
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.
-rw-r--r--lisp/json.el6
-rw-r--r--test/lisp/json-tests.el5
2 files changed, 9 insertions, 2 deletions
diff --git a/lisp/json.el b/lisp/json.el
index 5f403a411b7..3def94ce042 100644
--- a/lisp/json.el
+++ b/lisp/json.el
@@ -206,7 +206,11 @@ Unlike `reverse', this keeps the property-value pairs intact."
206 206
207(defun json-skip-whitespace () 207(defun json-skip-whitespace ()
208 "Skip past the whitespace at point." 208 "Skip past the whitespace at point."
209 (skip-chars-forward "\t\r\n\f\b ")) 209 ;; See
210 ;; https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
211 ;; or https://tools.ietf.org/html/rfc7159#section-2 for the
212 ;; definition of whitespace in JSON.
213 (skip-chars-forward "\t\r\n "))
210 214
211 215
212 216
diff --git a/test/lisp/json-tests.el b/test/lisp/json-tests.el
index 38672de0664..c6bd295d667 100644
--- a/test/lisp/json-tests.el
+++ b/test/lisp/json-tests.el
@@ -89,7 +89,10 @@ Point is moved to beginning of the buffer."
89(ert-deftest test-json-skip-whitespace () 89(ert-deftest test-json-skip-whitespace ()
90 (json-tests--with-temp-buffer "\t\r\n\f\b { \"a\": 1 }" 90 (json-tests--with-temp-buffer "\t\r\n\f\b { \"a\": 1 }"
91 (json-skip-whitespace) 91 (json-skip-whitespace)
92 (should (equal (char-after (point)) ?{)))) 92 (should (equal (char-after) ?\f)))
93 (json-tests--with-temp-buffer "\t\r\n\t { \"a\": 1 }"
94 (json-skip-whitespace)
95 (should (equal (char-after) ?{))))
93 96
94;;; Paths 97;;; Paths
95 98