[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master c87c87f 6/7: Escape NUL bytes in X selections (Bug#
From: |
Noam Postavsky |
Subject: |
[Emacs-diffs] master c87c87f 6/7: Escape NUL bytes in X selections (Bug#6991) |
Date: |
Thu, 29 Jun 2017 19:47:47 -0400 (EDT) |
branch: master
commit c87c87fcc361494815bbd1d92f450b0b80a3ecbb
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Escape NUL bytes in X selections (Bug#6991)
* lisp/term/w32-win.el (w32--set-selection):
* lisp/select.el (xselect--encode-string): Replace NUL bytes with
"\0".
* doc/emacs/killing.texi: Document new behavior.
* etc/NEWS (times): Announce it.
---
doc/emacs/killing.texi | 4 ++++
etc/NEWS | 4 ++++
lisp/select.el | 3 +++
lisp/term/w32-win.el | 2 +-
4 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/doc/emacs/killing.texi b/doc/emacs/killing.texi
index 47de053..0b5efd0 100644
--- a/doc/emacs/killing.texi
+++ b/doc/emacs/killing.texi
@@ -519,6 +519,10 @@ when exiting Emacs; if you wish to prevent Emacs from
transferring
data to the clipboard manager, change the variable
@code{x-select-enable-clipboard-manager} to @code{nil}.
+ Since strings containing NUL bytes are usually truncated when passed
+through the clipboard, Emacs replaces such characters with ``\0''
+before transfering them to the system's clipboard.
+
@vindex select-enable-primary
@findex clipboard-kill-region
@findex clipboard-kill-ring-save
diff --git a/etc/NEWS b/etc/NEWS
index 319b40f..dc9393c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -326,6 +326,10 @@ The old behaviour of using 'prin1' can be restored by
customizing the
new option 'debugger-print-function'.
+++
+** NUL bytes in strings copied to the system clipboard are now
+replaced with "\0".
+
++++
** The new variable 'x-ctrl-keysym' has been added to the existing
roster of X keysyms. It can be used in combination with another
variable of this kind to swap modifiers in Emacs.
diff --git a/lisp/select.el b/lisp/select.el
index 4849d7d..579c5c7 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -475,6 +475,9 @@ two markers or an overlay. Otherwise, it is nil."
(t
(error "Unknown selection type: %S" type)))))
+ ;; Most programs are unable to handle NUL bytes in strings.
+ (setq str (replace-regexp-in-string "\0" "\\0" str t t))
+
(setq next-selection-coding-system nil)
(cons type str))))
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index fda9388..be895a0 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -396,7 +396,7 @@ See the documentation of `create-fontset-from-fontset-spec'
for the format.")
;;; Fix interface to (X-specific) mouse.el
(defun w32--set-selection (type value)
(if (eq type 'CLIPBOARD)
- (w32-set-clipboard-data value)
+ (w32-set-clipboard-data (replace-regexp-in-string "\0" "\\0" value t t))
(put 'x-selections (or type 'PRIMARY) value)))
(defun w32--get-selection (&optional type data-type)
- [Emacs-diffs] master updated (138447c -> 169532b), Noam Postavsky, 2017/06/29
- [Emacs-diffs] master 522e3c1 1/7: Operate on frame list instead of printed backtrace, Noam Postavsky, 2017/06/29
- [Emacs-diffs] master b567c48 4/7: Don't redundantly cl-print arglist in function docstring again, Noam Postavsky, 2017/06/29
- [Emacs-diffs] master 0ae28c7 5/7: Hide byte code in backtraces (Bug#6991), Noam Postavsky, 2017/06/29
- [Emacs-diffs] master ead5458 2/7: Improve ert backtrace recording, Noam Postavsky, 2017/06/29
- [Emacs-diffs] master eb9d3ec 3/7: Escape control characters in backtraces (Bug#6991), Noam Postavsky, 2017/06/29
- [Emacs-diffs] master 169532b 7/7: ; Merge: Backtrace printing improvements (Bug#6991), Noam Postavsky, 2017/06/29
- [Emacs-diffs] master c87c87f 6/7: Escape NUL bytes in X selections (Bug#6991),
Noam Postavsky <=