branch: externals/websocket
commit de8073d667c709c8cacee0f496df12ec942de52d
Author: dickmao <none>
Commit: dickmao <none>
Is encode-coding-string (quote utf-8) necessary?
The cl-loop presumably produces the unibyte string from earlier
revisions. Wrapping that value in an `encode-coding-string` could only
change
the return value of websocket-mask.
---
websocket.el | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/websocket.el b/websocket.el
index 88c8c1b00b..31af67a1ac 100644
--- a/websocket.el
+++ b/websocket.el
@@ -46,6 +46,7 @@
(require 'bindat)
(require 'url-parse)
(require 'url-cookie)
+(require 'seq)
(eval-when-compile (require 'cl-lib))
;;; Code:
@@ -289,15 +290,11 @@ This is used to both mask and unmask data."
;; string of the same length (for example, 6 multibyte chars for 你好 instead
;; of the correct 6 unibyte chars, which would convert into 2 multibyte
;; chars).
- (funcall
- #'encode-coding-string
- (let ((result (make-string (length data) ?x)))
- (cl-loop
- for i from 0 below (length data)
- do
- (setf (seq-elt result i) (logxor (aref key (mod i 4)) (seq-elt data i)))
- finally (return result)))
- 'utf-8))
+ (cl-loop
+ with result = (make-string (length data) ?x)
+ for i from 0 below (length data)
+ do (setf (seq-elt result i) (logxor (aref key (mod i 4)) (seq-elt data i)))
+ finally return result))
(defun websocket-ensure-length (s n)
"Ensure the string S has at most N bytes.