aboutsummaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2026-06-12 16:49:48 +0000
committerDaniel Eklöf <daniel@ekloef.se>2026-06-12 16:49:48 +0000
commitca73ec71d5747d2c0c68b8b562cee3bb80b773ac (patch)
tree17759212e5ffd53422a1e795acc8a2cbe10a1ed5 /selection.c
parentosc: kitty text-size: bail out if text is zero-length (diff)
selection: escape quotes in file names being DnD:ed on the command line
Closes #2363
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/selection.c b/selection.c
index 4a62369d..dad81994 100644
--- a/selection.c
+++ b/selection.c
@@ -2098,7 +2098,16 @@ decode_one_uri(struct clipboard_receive *ctx, char *uri, size_t len)
if (ctx->quote_paths)
ctx->cb("'", 1, ctx->user);
- ctx->cb(path, strlen(path), ctx->user);
+ char *path_remaining = path;
+ for (char *next_quote = strchr(path_remaining, '\'');
+ next_quote != NULL;
+ path_remaining = next_quote + 1,
+ next_quote = strchr(path_remaining, '\''))
+ {
+ ctx->cb(path_remaining, next_quote - path_remaining, ctx->user);
+ ctx->cb("\\'", 2, ctx->user);
+ }
+ ctx->cb(path_remaining, strlen(path_remaining), ctx->user);
if (ctx->quote_paths)
ctx->cb("'", 1, ctx->user);