fix: stop URL-encoding drag-out filenames and preserve Unicode letters

This commit is contained in:
Linus Rath
2026-05-22 14:49:17 +02:00
parent ca0d6805cf
commit 0dca019fe5
3 changed files with 18 additions and 12 deletions
+5 -3
View File
@@ -92,9 +92,11 @@ export function useAttachmentDrag(
return;
}
// `DownloadURL` format: <mime>:<filename>:<url>. Chromium reads this on
// drop and writes a real file at the destination.
e.dataTransfer.setData("DownloadURL", `${type}:${encodeURIComponent(name)}:${url}`);
// `DownloadURL` format: <mime>:<filename>:<url>. The filename must be
// raw - URL-encoding it lands literally on disk (`%20` instead of a
// space). Callers are expected to sanitise reserved chars (`:` etc.)
// beforehand.
e.dataTransfer.setData("DownloadURL", `${type}:${name}:${url}`);
e.dataTransfer.effectAllowed = "copyMove";
},
[source.name, source.type, prefetch],