summaryrefslogtreecommitdiff
path: root/test/lisp
diff options
context:
space:
mode:
authorMark Oteiza <mvoteiza@udel.edu>2017-08-17 20:00:52 -0400
committerMark Oteiza <mvoteiza@udel.edu>2017-08-17 20:00:52 -0400
commit87645443b5c6dffea928a19c50aded605a28279c (patch)
tree77aa4d12f627f56250df2913f9eb5f1090a28cc7 /test/lisp
parent61631476d79cdb10272091251f3b84817fbc631a (diff)
downloademacs-87645443b5c6dffea928a19c50aded605a28279c.tar.gz
Treat control characters in JSON strings as invalid
* lisp/json.el (json-peek): Reduce to following-char. (json-pop, json-read): Zero (null char) means end of file. (json-read-escaped-char): Delimit URL properly. (json-read-string): Signal error for ASCII control characters. * test/lisp/json-tests.el (test-json-peek): Check for zero instead of :json-eof symbol. (test-json-read-string): New test for control characters in JSON strings.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/json-tests.el4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/lisp/json-tests.el b/test/lisp/json-tests.el
index c6bd295d667..1d13ccf074f 100644
--- a/test/lisp/json-tests.el
+++ b/test/lisp/json-tests.el
@@ -75,7 +75,7 @@ Point is moved to beginning of the buffer."
(ert-deftest test-json-peek ()
(json-tests--with-temp-buffer ""
- (should (eq (json-peek) :json-eof)))
+ (should (zerop (json-peek))))
(json-tests--with-temp-buffer "{ \"a\": 1 }"
(should (equal (json-peek) ?{))))
@@ -164,6 +164,8 @@ Point is moved to beginning of the buffer."
(should (equal (json-read-escaped-char) ?\"))))
(ert-deftest test-json-read-string ()
+ (json-tests--with-temp-buffer "\"formfeed\f\""
+ (should-error (json-read-string) :type 'json-string-format))
(json-tests--with-temp-buffer "\"foo \\\"bar\\\"\""
(should (equal (json-read-string) "foo \"bar\"")))
(json-tests--with-temp-buffer "\"abcαβγ\""