From a6a9c909b728f515cd10c09d682f52b710c202d3 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 15 Aug 2026 11:31:08 +1000 Subject: [PATCH] [client] clipboard: fix pasting into Nautilus Yet again we have to implement a fix for another Gnome-ism. Why they dont just implement standard such as rfc2483 is beyond me. Instead they have decided to implement the undocumented format `x-special/gnome-copied-files`. You would think that they could at least remain compatible by trimming `\r` from the lines. I am so glad KDE is good these days --- client/src/clipboard_files.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/client/src/clipboard_files.c b/client/src/clipboard_files.c index 7f992658..a4f98c17 100644 --- a/client/src/clipboard_files.c +++ b/client/src/clipboard_files.c @@ -2160,15 +2160,17 @@ static bool getRemoteDatasetNL(struct RemoteDataset * dataset, } if (strcmp(mime, FILE_URI_MIME) && strcmp(mime, FILE_GNOME_MIME)) return false; + + const bool gnome = !strcmp(mime, FILE_GNOME_MIME); char * result = NULL; size_t used = 0; size_t capacity = 0; - if (!strcmp(mime, FILE_GNOME_MIME)) + if (gnome) { - if (!grow((void **)&result, &capacity, 6U)) + if (!grow((void **)&result, &capacity, 5U)) return false; - memcpy(result, "copy\n", 5U); - used = 5U; + memcpy(result, "copy", 4U); + used = 4U; } for (struct RemoteNode * node = files.remoteNodes; node; node = node->next) { @@ -2185,14 +2187,20 @@ static bool getRemoteDatasetNL(struct RemoteDataset * dataset, free(raw); if (!encoded) goto error; + const size_t line = strlen(FILE_URI_PREFIX) + strlen(encoded) + 2U; if (!grow((void **)&result, &capacity, used + line + 1U)) { free(encoded); goto error; } - used += (size_t)snprintf(result + used, capacity - used, - FILE_URI_PREFIX "%s\r\n", encoded); + + if (gnome) + used += (size_t)snprintf(result + used, capacity - used, + "\n" FILE_URI_PREFIX "%s", encoded); + else + used += (size_t)snprintf(result + used, capacity - used, + FILE_URI_PREFIX "%s\r\n", encoded); free(encoded); } if (!result)