summaryrefslogtreecommitdiff
path: root/lisp/select.el
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2017-02-11 19:47:55 -0500
committerNoam Postavsky <npostavs@gmail.com>2017-06-29 19:40:23 -0400
commitc87c87fcc361494815bbd1d92f450b0b80a3ecbb (patch)
tree60d7ae515b92944d1e90772df3ae5dac05b5c715 /lisp/select.el
parent0ae28c71c739dfecbe94a5ff6786e81021d2d1cf (diff)
downloademacs-c87c87fcc361494815bbd1d92f450b0b80a3ecbb.tar.gz
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.
Diffstat (limited to 'lisp/select.el')
-rw-r--r--lisp/select.el3
1 files changed, 3 insertions, 0 deletions
diff --git a/lisp/select.el b/lisp/select.el
index 4849d7d515e..579c5c7e2ee 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))))