]> code.delx.au - gnu-emacs/blobdiff - lisp/json.el
Update char-script-table
[gnu-emacs] / lisp / json.el
index fb0f62c877794747d158bf378f7af3fabe87e9c2..eaf8596a6dc8649e6e6e01a5a42c2751e77b856f 100644 (file)
 
 ;;; Code:
 
-
-;; Compatibility code
-
-(defalias 'json-decode-char0 'decode-char)
-
-
 ;; Parameters
 
 (defvar json-object-type 'alist
@@ -264,7 +258,6 @@ representation will be parsed correctly."
 (defvar json-special-chars
   '((?\" . ?\")
     (?\\ . ?\\)
-    (?/ . ?/)
     (?b . ?\b)
     (?f . ?\f)
     (?n . ?\n)
@@ -286,7 +279,7 @@ representation will be parsed correctly."
      ((looking-at "[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]")
       (let ((hex (match-string 0)))
         (json-advance 4)
-        (json-decode-char0 'ucs (string-to-number hex 16))))
+        (string-to-number hex 16)))
      (t
       (signal 'json-string-escape (list (point)))))))
 
@@ -319,8 +312,9 @@ representation will be parsed correctly."
   (let ((l (length string))
         (start 0)
         res mb)
-    ;; Skip over ASCIIish printable characters.
-    (while (setq mb (string-match "[\"\\/\b\f\n\r\t]\\|[^ -~]" string start))
+    ;; Only escape quotation mark, backslash and the control
+    ;; characters U+0000 to U+001F (RFC 4627, ECMA-404).
+    (while (setq mb (string-match "[\"\\[:cntrl:]]" string start))
       (let* ((c (aref string mb))
              (special (rassq c json-special-chars)))
         (push (substring string start mb) res)