From 5ab49de7f2aea28018c67ff4e646d68ad187f52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 19 Oct 2021 21:34:04 +0200 Subject: [PATCH] selection: convert \r -> \n when reading clipboard data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes an issue where pasting (using e.g. OSC-52) in client applications that doesn’t do this conversion themselves, like tmux, doesn’t work. Closes #752 --- CHANGELOG.md | 2 ++ selection.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c445a445..d87b632f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,8 @@ state, foot was looking at **depressed** modifiers, not **effective** modifiers, like it should. * Fix crashes after enabling CSD at runtime when `csd.size` is 0. +* Convert `\r` to `\n` when reading clipboard data + (https://codeberg.org/dnkl/foot/issues/752). ### Security diff --git a/selection.c b/selection.c index b6bae978..91523d3b 100644 --- a/selection.c +++ b/selection.c @@ -1609,6 +1609,11 @@ fdm_receive_timeout(struct fdm *fdm, int fd, int events, void *data) static void fdm_receive_decoder_plain(struct clipboard_receive *ctx, char *data, size_t size) { + /* \r -> \n */ + for (size_t i = 0; i < size; i++) { + if (data[i] == '\r') + data[i] = '\n'; + } ctx->cb(data, size, ctx->user); }