Permalink
Browse files

fix decoding of multibyte netstrings

  • Loading branch information...
1 parent e1042e2 commit 037007ba3254c82168bfbffdf11a8cb3a7c76a51 @kingtim kingtim committed Jun 20, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −1 nrepl.el
  2. +14 −0 test/nrepl-tests.el
View
@@ -166,7 +166,7 @@ Empty strings and duplicates are ignored."
((looking-at "\\([0-9]+\\):")
(goto-char (match-end 0))
(let ((start (point))
- (end (+ (point) (string-to-number (match-string 1)))))
+ (end (byte-to-position (+ (position-bytes (point)) (string-to-number (match-string 1))))))
(goto-char end)
(buffer-substring-no-properties start end)))
((looking-at "l")
View
@@ -110,3 +110,17 @@
applying f to that result and the 2nd item, etc. If coll contains no
items, returns val and f is not called.
7:session36:6fc999d0-3795-4d51-85fc-ccca7537ee57ed2:id2:182:ns4:user7:session36:6fc999d0-3795-4d51-85fc-ccca7537ee575:value3:niled2:id2:187:session36:6fc999d0-3795-4d51-85fc-ccca7537ee576:statusl4:doneee"))))
+
+(ert-deftest test-nrepl-decode-nrepl-response-multibyte ()
+ (assert (equal '((dict
+ ("id" . "42")
+ ("ns" . "user")
+ ("session" . "3f586403-ed47-4e4d-b8db-70522054f971")
+ ("value" . "\"\""))
+ (dict
+ ("id". "42")
+ ("session" . "3f586403-ed47-4e4d-b8db-70522054f971")
+ ("status" "done")))
+ (nrepl-decode
+ "d2:id2:422:ns4:user7:session36:3f586403-ed47-4e4d-b8db-70522054f9715:value5:\"\"ed2:id2:427:session36:3f586403-ed47-4e4d-b8db-70522054f9716:statusl4:doneee"))))
+

0 comments on commit 037007b

Please sign in to comment.