From 087c5c1db9fecc43f068d37346955d6a04ca8eab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Apr 2026 03:19:41 +0000 Subject: [PATCH] dnd.c: strip query and fragment parts from file:// URLs before path resolution Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/8293fefc-4d7c-4502-9646-6270328d4a59 Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com> --- docs/changelog.rst | 2 ++ kitty/dnd.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 92e8306b7..416b4ac02 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -183,6 +183,8 @@ Detailed list of changes - :doc:`Remote control `: Expose :code:`session_name` in the output of ``kitten @ ls`` for each window (:iss:`9732`) +- Drag and drop: Ignore query and fragment parts of ``file://`` URLs when parsing dropped file paths + - Fix thickness of diagonal lines in box drawing characters not the same as horizontal/vertical lines (:iss:`9719`) - Graphics protocol: Fix crash when handling invalid PNG image with direct transmission diff --git a/kitty/dnd.c b/kitty/dnd.c index 3989f36f2..2b2d5fbd2 100644 --- a/kitty/dnd.c +++ b/kitty/dnd.c @@ -488,6 +488,9 @@ get_nth_file_url(const char *uri_list, size_t uri_list_sz, int n, char **path_ou RAII_ALLOC(char, path, strdup(slash)); if (!path) { *error_out = "ENOMEM"; return false; } + /* Strip any query (?...) or fragment (#...) from the path */ + char *query_or_fragment_start = path + strcspn(path, "?#"); + *query_or_fragment_start = 0; url_decode_inplace(path); if (path[0] != '/') { *error_out = "EINVAL"; return false; }