From 59fe724b277021238e772a9bf4e7a5a69e784f24 Mon Sep 17 00:00:00 2001 From: Akib Azmain Turja Date: Fri, 16 Dec 2022 14:48:24 +0600 Subject: [PATCH] Decoding UTF-8 encoded strings encoded as base64 * eat.el (eat--t-set-cwd): Decoding UTF-8 encoded strings encoded as base64. * eat.el (eat--t-manipulate-selection): Use 'ignore-errors' instead of '(ignore-error ...)', since both macro expand to the same code. * eat.el (eat--t-set-cmd): Decoding UTF-8 encoded strings encoded as base64. Use 'when-let*' instead of 'when' nested in 'let'. --- eat.el | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/eat.el b/eat.el index 996e966..c009956 100644 --- a/eat.el +++ b/eat.el @@ -2357,8 +2357,12 @@ the format \"file://HOST/CWD/\"; HOST can be empty." ('base64 (let ((dir (ignore-errors (expand-file-name (file-name-as-directory - (base64-decode-string path))))) - (hostname (ignore-errors (base64-decode-string host)))) + (decode-coding-string + (base64-decode-string path) + locale-coding-system))))) + (hostname (ignore-errors (decode-coding-string + (base64-decode-string host) + locale-coding-system)))) (when (and dir hostname) ;; Update working directory. (setf (eat--t-term-cwd eat--t-term) (cons hostname dir)) @@ -2474,7 +2478,7 @@ DATA is the selection data encoded in base64." (base64-encode-string str)))) ;; The client is requesting to set clipboard content, let's try to ;; fulfill the request. - (let ((str (ignore-error error + (let ((str (ignore-errors (decode-coding-string (base64-decode-string data) locale-coding-system)))) (seq-doseq (target targets) @@ -2519,9 +2523,10 @@ DATA is the selection data encoded in base64." (defun eat--t-set-cmd (cmd) "Set the command being executed to CMD." - (let ((c (ignore-errors (base64-decode-string cmd)))) - (when c - (funcall (eat--t-term-set-cmd-fn eat--t-term) eat--t-term c)))) + (when-let* ((c (ignore-errors (decode-coding-string + (base64-decode-string cmd) + locale-coding-system)))) + (funcall (eat--t-term-set-cmd-fn eat--t-term) eat--t-term c))) (defun eat--t-cmd-start () "Call shell command start hook."