>From 4f49294621e64a20462c369499d128523bf4a5de Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 11 Feb 2017 19:47:55 -0500 Subject: [PATCH v1 5/5] 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 a4a79255a9..705d6469d3 100644 --- a/lisp/select.el +++ b/lisp/select.el @@ -475,6 +475,9 @@ xselect--encode-string (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