Skip to content

Commit

Permalink
fix decoding of multibyte netstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
kingtim committed Jun 20, 2012
1 parent e1042e2 commit 037007b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nrepl.el
Expand Up @@ -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")
Expand Down
14 changes: 14 additions & 0 deletions test/nrepl-tests.el
Expand Up @@ -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.