>From 57e94182464e6d6fec3e0f7dccdda8a45abf38df Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 11 Feb 2017 19:47:55 -0500 Subject: [PATCH v2 5/6] Escape NUL bytes in X selections (Bug#6991) * lisp/select.el (xselect--encode-string): Replace NUL bytes with "\0". --- lisp/select.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/select.el b/lisp/select.el index 4849d7d515..579c5c7e2e 100644 --- a/lisp/select.el +++ b/lisp/select.el @@ -475,6 +475,9 @@ (defun xselect--encode-string (type str &optional can-modify) (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)))) -- 2.11.1