Allow frames to contain carriage returns without removing them

master
Hugo Thunnissen 6 years ago
parent 1f9ce5430f
commit f886fe49b8

@ -56,9 +56,6 @@
frame (from top to bottom) will be read. If there are no frame (from top to bottom) will be read. If there are no
frames in the buffer, nil will be returned." frames in the buffer, nil will be returned."
(with-current-buffer buffer (with-current-buffer buffer
(goto-char (point-min))
(while (search-forward "\r" nil t)
(replace-match ""))
(let ((frame ()) (let ((frame ())
(headers-end-point (stomp-find-headers-end-point buffer)) (headers-end-point (stomp-find-headers-end-point buffer))
(frame-end-point (stomp-find-frame-end-point buffer))) (frame-end-point (stomp-find-frame-end-point buffer)))
@ -84,13 +81,13 @@
(t (stomp-read-headers buffer end-point (t (stomp-read-headers buffer end-point
(map-put headers (map-put headers
(car header) (car header)
(replace-regexp-in-string "\n$" "" (car (last header)))))))))) (replace-regexp-in-string "\\(\n\\|\r\n\\)$" "" (car (last header))))))))))
(defun stomp-find-frame-end-point (buffer) (defun stomp-find-frame-end-point (buffer)
"Find the null byte at the end of a STOMP frame" "Find the null byte at the end of a STOMP frame"
(with-current-buffer buffer (with-current-buffer buffer
(goto-char (point-min)) (goto-char (point-min))
(search-forward "\u0000") (search-forward-regexp "\u0000\\|\u0000\r")
(- (point) 1))) (- (point) 1)))
(defun stomp-find-headers-end-point (buffer) (defun stomp-find-headers-end-point (buffer)
@ -98,7 +95,7 @@
(with-current-buffer buffer (with-current-buffer buffer
(goto-char (point-min)) (goto-char (point-min))
(condition-case nil (condition-case nil
(progn (search-forward-regexp "^$") (line-end-position)) (progn (search-forward-regexp "^\\(\\|\r\\)$") (line-end-position))
(error nil)))) (error nil))))
(defun stomp-frame-to-string (frame) (defun stomp-frame-to-string (frame)

@ -46,7 +46,7 @@
(should (equal (alist-get 'headers recieved) (should (equal (alist-get 'headers recieved)
'(("ok" . "bye") '(("ok" . "bye")
("some-header" . "value")))) ("some-header" . "value"))))
(should (equal (alist-get 'content recieved) "content\n")))) (should (equal (alist-get 'content recieved) "content\r\n"))))
(ert-deftest can-delete-one-frame () (ert-deftest can-delete-one-frame ()
"Can delete the topmost frame in a buffer" "Can delete the topmost frame in a buffer"

Loading…
Cancel
Save