emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 88847dee125: Jsonrpc: don't bind inhibit-read-only to t so earl


From: João Távora
Subject: emacs-29 88847dee125: Jsonrpc: don't bind inhibit-read-only to t so early
Date: Fri, 7 Apr 2023 14:31:46 -0400 (EDT)

branch: emacs-29
commit 88847dee125aa333b79829744eb4b16e8fd59ee8
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Jsonrpc: don't bind inhibit-read-only to t so early
    
    Related to https://github.com/joaotavora/eglot/discussions/1202, where
    because of this very wide binding to inhibit-read-only to t, Eglot was
    managing to write into read-only buffers from the response handlers
    that ran from within the stack of the jsonrpc.el process filter.
    
    This is of course illegal and dangerous, but Eglot wasn't made aware
    because of the binding.
    
    * lisp/jsonrpc.el (jsonrpc--process-filter): Don't bind
    inhibit-read-only so early.
---
 lisp/jsonrpc.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el
index f583d116d20..3f9d4a7e818 100644
--- a/lisp/jsonrpc.el
+++ b/lisp/jsonrpc.el
@@ -566,15 +566,14 @@ With optional CLEANUP, kill any associated buffers."
     (cl-return-from jsonrpc--process-filter))
   (when (buffer-live-p (process-buffer proc))
     (with-current-buffer (process-buffer proc)
-      (let* ((inhibit-read-only t)
-             (jsonrpc--in-process-filter t)
+      (let* ((jsonrpc--in-process-filter t)
              (connection (process-get proc 'jsonrpc-connection))
              (expected-bytes (jsonrpc--expected-bytes connection)))
         ;; Insert the text, advancing the process marker.
         ;;
         (save-excursion
           (goto-char (process-mark proc))
-          (insert string)
+          (let ((inhibit-read-only t)) (insert string))
           (set-marker (process-mark proc) (point)))
         ;; Loop (more than one message might have arrived)
         ;;
@@ -623,7 +622,8 @@ With optional CLEANUP, kill any associated buffers."
                                     (jsonrpc-connection-receive connection
                                                                 
json-message)))))
                           (goto-char message-end)
-                          (delete-region (point-min) (point))
+                          (let ((inhibit-read-only t))
+                            (delete-region (point-min) (point)))
                           (setq expected-bytes nil))))
                      (t
                       ;; Message is still incomplete



reply via email to

[Prev in Thread] Current Thread [Next in Thread]