aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-10-19 19:34:04 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-10-19 19:34:04 +0000
commit5ab49de7f2aea28018c67ff4e646d68ad187f52d (patch)
tree2b77076baf06056ec1097f0a02794f278cc773de
parentMerge branch 'nordiq' (diff)
selection: convert \r -> \n when reading clipboard data
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
-rw-r--r--CHANGELOG.md2
-rw-r--r--selection.c5
2 files changed, 7 insertions, 0 deletions
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);
}